[Rcpp-devel] Rcpp build trouble with strings

Dirk Eddelbuettel edd at debian.org
Fri Aug 16 19:52:37 CEST 2013


On 16 August 2013 at 13:45, jacob.a.russell.th at dartmouth.edu wrote:
| Hello,
| 
| I am trying to build a package but I have quite a few dependencies. As such, I
| have modified Makevars to be (I don't like backticks because I find them too
| similar to single quotes):
| 
| PKG_LIBS = $($(R_HOME)/bin/Rscript -e 'Rcpp:::LdFlags()') -L. -llink_4_1b -lDGG -lSTR -lDLL -lAF -lmy_std -lm
| PKG_CPPFLAGS=-I. -g
| 
| Which seems to compile when my R wrapper is (incorrectly):
| 
| RcppExport SEXP getDocGraph(std::string input){
|     
|     std::string testStr = input;
|     std::string output=getDG(testStr);
|     return(Rcpp::wrap(output));
| }
| 
| but then it gives me a segmentation fault because it cannot access the
| underlying character array (or general object) passed in by R.
| 
| Then if I change the function protoype to:
| 
| RcppExport SEXP getDocGraph(SEXP input){
|     
|     std::string testStr = Rcpp::as<std::string>(input);
|     std::string output=getDG(testStr);
|     return(Rcpp::wrap(output));
| }
| 
| it seems to compile, but when I go to check the package, the .Rcheck directory
| gives me an error:
| 
| ** testing if installed package can be loaded
| Error in dyn.load(file, DLLpath = DLLpath, ...) : 
|   unable to load shared object ...<packagename>.so':
| 
| and the .so file is not in the tgz package, but no error was given during
| compilation.
| 
| Any help is greatly appreciated.

Simplify. 

I would start by removing your six additional libraries and convince myself
that accessing a string via Rcpp works (and as our unit tests do that a lot,
you would have to be in a very unusual situation to not have it work).

Once that works, add your libraries. If and when things break again, examine
the differences.

Dirk

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


More information about the Rcpp-devel mailing list