Hi Chaomei, On 23 April 2014 at 14:57, Chaomei Lo wrote: | I am testing the TRNG (Random number generation) using Rcpp, but it seems like | the PKG_CPPFLAGS and PKG_LIBS not being picked for compilation and creating | shared library. I invoked the R shell right above the “trng”. I would recommend to use a package instead.
Then you can set whatever you need in src/Makevars. sourceCpp() was not designed for this. If you insist, you can write yourself your own plugin (see eg the Rcpp FAQ) but you may still want a package to provide the plugin. I suspect you are getting bitten here in as much as the environment variables being set to R and affect one subshell which calls 'R CMD ...' but not into the commands being spawned by R. In a nutshell, this method is not documented to work, so just don't do it... Dirk | | > getwd() | | [1] "/people/mei/trng-4.15" | | > library(Rcpp) | | > Sys.setenv(“PKG_CPPFLAGS”=”-I.”) | | > Sys.setenv(“PKG_CXXFLAGS”=”-fopenmp”) | | > Sys.setenv(“PKG_LIBS”=”-L/people/mei/trng-4.15/conf_prefix/lib -ltrng4″) | | > sourceCpp(“prunif.cpp”) | | prunif.cpp:4:26: fatal error: trng/yarn2.hpp: No such file or directory | | compilation terminated. | | make: *** [prunif.o] Error 1 | | g++ -I/people/mei/softwarelib/R-3.0.2/include -DNDEBUG -I. -I/usr/local/include | -I”/people/mei/softwarelib/R-3.0.2/library/Rcpp/include” -fopenmp -fpic -g -O2 | -c prunif.cpp -o prunif.o | | Error in sourceCpp(“prunif.cpp”) : | | Error 1 occurred building shared library. | | | | Thanks. | | | ---------------------------------------------------------------------- | _______________________________________________ | Rcpp-devel mailing list | [email protected] | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
