[R] linking to external C++ library

Dirk Eddelbuettel edd at debian.org
Fri Nov 20 03:29:52 CET 2009


On 19 November 2009 at 20:57, David Scherrer wrote:
| I don't bring my head around how to link an external C++ library with some R
| code using R CMD SHLIB and/or R CMD INSTALL .
| 
| So does anybody can tell me how I could easily link an external library that
| is e.g. in
| /usr/local/lib/mMyLibrary ?

Prefix 'R CMD SHLIB ...' with settings for PKG_LIBS and/or PKG_CPPFLAGS
and/or PKG_CXXFLAGS:

    $ PKG_LIBS="-L/usr/local/lib/mMyLibrary -lsomelibrary" \
      PKG_CPPFLAGS="-I... -Wall" \	    
      R CMD SHLIB foo.cpp  

on the command-line, or if that is too fiddly, create a package. There are
literally dozens of packages on CRAN (and R-Forge) to copy from.  

Dirk
					
-- 
Three out of two people have difficulties with fractions.




More information about the R-help mailing list