From simon.urbanek at r-project.org  Sat Jul  6 04:19:21 2013
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 5 Jul 2013 22:19:21 -0400
Subject: [Rd] Cross-platform linking of a simple front-end
In-Reply-To: <CAM9CR=2z8UWuwtHXV+HsbHqOF9aSe1-mYP72WTe7pf2q+zMXcg@mail.gmail.com>
References: <CAM9CR=2z8UWuwtHXV+HsbHqOF9aSe1-mYP72WTe7pf2q+zMXcg@mail.gmail.com>
Message-ID: <0D58AA12-6314-4277-8570-A7C87F291516@r-project.org>

Jon,

On Jul 4, 2013, at 10:52 AM, Jon Clayden wrote:

> Dear all,
> 
> I have a simple front-end program which uses the APIs described in section
> 8 of "Writing R Extensions" to deviate from the standard R behaviour in
> fairly minor ways. However, I'm having some difficulty getting it to link
> reliably across different platforms.
> 
> R CMD LINK seemed like it would help, but I've had difficulty finding many
> real-world examples online. I've tried
> 
>  R CMD LINK $(R CMD config CC) $(R CMD config --cppflags) $(R CMD config
> --ldflags) -o ../bin/exec/tractor tractor.c
> 
> and this works on one of my test platforms (OS X.8.4, R 3.0.1), but not the
> other (Ubuntu 12.04 LTS, R 2.14.1). In the latter case I get the error
> 
>  /usr/bin/ld: /tmp/ccmKf57E.o: undefined reference to symbol 'log10@
> @GLIBC_2.0'
>  /usr/bin/ld: note: 'log10@@GLIBC_2.0' is defined in DSO
> /lib/i386-linux-gnu/libm.so.6 so try adding it to the linker command line
>  /lib/i386-linux-gnu/libm.so.6: could not read symbols: Invalid operation
>  collect2: ld returned 1 exit status
> 
> I can correct this by adding "-lm" manually to the command, but I'm not
> sure how portable that will itself be.
> 

My guess would be that you did not use --enable-R-shlib when compiling R on Ubuntu so you don't have a shared version of the R library to link against (which is needed to resolve the dependencies). Could that be the case?

Cheers,
Simon


> Could anyone advise on the best way to make this work portably, please? For
> this application I'm not concerned about Windows compatibility -
> portability across Unix-alikes is sufficient. The source code is at <
> https://github.com/jonclayden/tractor/blob/master/src/tractor.c>, if that
> is useful.
> 
> All the best,
> Jon
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] Cross-platform linking of a simple front-end
Simon Urbanek