Skip to content
Prev 2269 / 10988 Next

[Rcpp-devel] Create and access several instances of a C++ class from R

On 13.05.2011, at 18:55, Dirk Eddelbuettel wrote:

            
Hello Dirk

Compilation with R CMD CHECK FOO fails with the following error in 00install.out:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Users/sovo/GUTS/FOO.Rcheck/FOO/libs/i386/FOO.so':
  dlopen(/Users/sovo/GUTS/FOO.Rcheck/FOO/libs/i386/FOO.so, 6): Symbol not found: __ZN3FOOC1Ev
  Referenced from: /Users/sovo/GUTS/FOO.Rcheck/FOO/libs/i386/FOO.so
  Expected in: flat namespace

The (original) class and its functions compile fine with R CMD SHLIB. So we guess that this error has something to do with the Rcpp modules implementation.

Currently, FOO_mod.cpp is embedded in a package "FOO" created with Rcpp.pack...("FOO", module=TRUE), DESCRIPTION and NAMESPACE were adjusted accordingly, all other C sources were removed. Recapture that the package compiled and installed with our previous FOO version, however, since we wanted to use pointers, rewriting was necessary. After that, even exposing a blank class (FOO without anything, except the constructor, but that again without parameters) fails with the error above. I guess that we still do not manage to expose the variables and the one method used in the class to R -- but we have no idea how to accomplish. If I know how to do it with one, say, int, one vector and the one method, perhaps I could understand how to do for the (many more) other variables in the complete class (indeed, FOO is only a reduced example).

What we want to prevent is to completely write the C-code for R use only. The best solution would be to change only some lines of code or even write a simple wrapper for the header file containing the class (there in C++). However, we thought it would be helpful to get it working in the first place, and then reengineer the code back to a more modular source.

Thank you for your help
S?ren