[Rd] Linking to headers and shared library in another package

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 11 19:33:26 CET 2008


Please review the latest version of 'Writing R Extensions'.  What is 
documented there has been tested with packages in different libraries, 
including none in $(R_HOME)/library.

Note however that on a Unix-alike linking even to 
$(R_HOME)/library/firstPkg/libs/firstPkg.so cannot work in general as that 
location is not in the ld.so search path when R is started and so the .so 
will not be located.

On Tue, 11 Nov 2008, Iago Mosqueira wrote:

> Hi,
>
> A package with some C code needs to use the headers and shared library
> in another package during installation/compilation. The first one is
> achieved through the LinkingTo option in DESCRIPTION. For the second a
> Makevars file with
>
> PKG_LIBS=$(R_HOME)/library/firstPkg/libs/firstPkg.so
>
> was being used. Problem this is not portable if the firstPkg package is
> not installed in the library folder inside R_HOME but lives somewhere else.
>
> What is the best way for Makevars or configure to find where a package
> lives? Or is there any other way to make sure the linking step finds
> where the shared library is located?

See the Windows examples in 'Writing R Extensions' (for this can be made 
to work on Windows).

>
> Apologies if I missed something in the extensions manual, but my limited
> experience with autoconf might have made me not notice it.
>
> Many thanks,
>
>
> Iago
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list