Hello Darren, Thank you for your advice. It makes good sense.
I now have a linker problem, and I have written some code to abstract the problem for your viewing. The error message is: "Error in dyn.load(libLFile) : unable to load shared object '/tmp/RtmpBFr1mw/file44b636b6.so': /tmp/RtmpBFr1mw/file44b636b6.so: undefined symbol: _Z6sumvecSt6vectorIiSaIiEE" It seems safe to say that it cannot find the cpp file for LinkTest.h The problem might be with how to use the"includes" argument for cxxfunction (see 1.b below). It seems a common enough problem, but I have not been able to gain a clearer understanding by reading past comments on it, as most of these seem to pertain to packages. So I will post the relevant code here, and the full output from verbose=TRUE below it: 1. R Calling Function linktest<-cxxfunction( signature( vec = "numeric", len = "integer" ), paste( readLines( "/home/simon/College/PackageOne/src/BZip/LinkTestWrap.cpp"),collapse = "\n" ) , plugin = "Rcpp",verbose=TRUE ) 1.b I also tried using user includes in the cxxfunction, and taking them out of the cpp file. But they don't seem to be parse properly in the created code, i.e.: "// user includes /home/simon/College/PackageOne/src/BZip/LinkTest.h" which the compiler naturally flags. 2. LinkTestWrap.cpp: Rcpp Wrapping Function (for use by inline) #include <Rcpp.h> #include <vector> #include "/home/simon/College/PackageOne/src/BZip/LinkTest.h" using std::vector; vector<int> input_vector( as< vector<int> >( vec ) ); int length = as<int> ( len ); int res = sumvec( input_vector ); return Rcpp::wrap( res ); 3. LinkTest.h #include <vector> int sumvec(std::vector<int> vec); 4.LinkTest.cpp #include "/home/simon/College/PackageOne/src/BZip/LinkTest.h" using std::vector; int sumvec(vector<int> vec){ int total = 0; for( vector<int>::const_iterator it = vec.begin(); it != vec.end(); ++it ){ total += *it; } return total; } Thanks again, Simon I thought the problem is with inline though. To take the link you gave: http://stackoverflow.com/questions/3221422/gcc-template-error One answer cites: "The errors that you have posted suggest that the problem is within the function void init_module_PyCML(). It would therefore appear that you have tried to define a function template within the body of another function." I interpreted this to be due to inline because the problem with static member variables certainly seems to be because the class and other code is defined within a wrapper function by inline. On Wed, Oct 12, 2011 at 12:24 AM, Darren Cook <dar...@dcook.org> wrote: > > My apologies for not posting comprehensive code. My intention was only to > > lessen the reading burden for you. > > Don't post comprehensive code :-) > But if you can discover the smallest possible example that shows the > problem, that will encourage lots of helpful responses. > > > > I am currently getting this error: > > > > /home/simon/College/PackageOne/src/BZip/BinaryTree.h: In function > ‘SEXPREC* > > file354d98a8(SEXPREC*, SEXPREC*)’: > > /home/simon/College/PackageOne/src/BZip/BinaryTree.h:8:1: error: expected > > primary-expression before ‘template’ > > /home/simon/College/PackageOne/src/BZip/BinaryTree.h:8:1: error: expected > > ‘;’ before ‘template’ > > > This is saying that you've not finished a statement before defining > another one. E.g. see > http://stackoverflow.com/questions/3221422/gcc-template-error > > It could mean a missing semi-colon in the file being included before > this one. If there are no statements or #include lines before line 8 in > BinaryTree.h, look at the files that include BinaryTree.h. > > > I think I can see a quick solution, (not to use the template - I don''t > > need genericity here anyway,)... > > If that is true, then the Smallest Possible Example would be very > interesting to the Rcpp developers, I'm sure. > > Darren > > > -- > Darren Cook, Software Researcher/Developer > > http://dcook.org/work/ (About me and my work) > http://dcook.org/blogs.html (My blogs and articles) > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel