[Rcpp-devel] How to use external C++ libraries in R packages withRcpp.

Dirk Eddelbuettel edd at debian.org
Wed Sep 4 13:51:01 CEST 2013


On 4 September 2013 at 18:21, guxiaobo1982 wrote:
| Hi Dirk,
|  
| Thanks for you help, here is wha I got in a test package:
|  
| 1.Rcpp.package.skeleton("cpptest")

Good start!

| 2. Add the following line to Makevars
|  
| PKG_CPPFLAGS=-I/opt/boost_1_54_0/include -I../inst/include PKG_LIBS = -L/opt/
| boost_1_54_0/lib -lboost_regex `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`

Those have to be __two distinct lines__ not one glued together. Try

PKG_CPPFLAGS=-I/opt/boost_1_54_0/include -I../inst/include 
PKG_LIBS = -L/opt/boost_1_54_0/lib -lboost_regex `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`

ie one assignment each to two variables PKG_CPPFLAGS and PKG_LIBS.

| 3. Change  rcpp_hello_world.cpp to this:

Looks good, and should work.  Boost Regex use is a nice small example.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list