On 19 July 2012 at 10:25, Lescai, Francesco wrote: | Thanks, it definitely pointed me in the right direction. | I added the additional flag needed by the compiler | using | PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e | 'Rcpp:::LdFlags()'` PKG_LIBS="$PKG_LIBS -lre2" R CMD SHLIB | | and now in dyn.load I have a symbol error demangled as | typeinfo for Rcpp::not_compatible
AFAICT that is a _run-time error_ pointing to a possible issue with the logic of your code, rather than a build issue. Just go on and debug.... Dirk | I've tested a C++ implementation (partial, the project is not quite complete), | and it seems to work. | I had some problems in installing boost regular expression libraries on Mac | OSx, so I'm using re2 which doesn't special requirements. | It works in C++, but if that's the problem with linking to R then I have to | think to alternative solutions. | | thanks Douglas and Dirk for your help, | Francesco | | | On 19 Jul 2012, at 02:01, Dirk Eddelbuettel wrote: | | | | On 18 July 2012 at 11:47, Douglas Bates wrote: | | One way forward is to use a program like c++filt to demangle the name | | that is not found. It is | | | | re2::RE2::Arg::parse_float(char const*, int, void*) | | I would also recommend to simplify as much as possible. In such a | situation, | I'd try to build a working C++ implementation (without any Rcpp or R) first | to make the design is right. | | Dirk | | | | | On Wed, Jul 18, 2012 at 11:18 AM, Lescai, Francesco <[email protected]> | wrote: | | > I'm still having this problem. | | > I progressively increased the complexity of my code, because my | ultimate | | > goal is to integrate a series of C++ classes to perform some functions | | > external to R. | | > | | > My test examples worked well, and I just noticed in order to generate | the | | > shared object I have to compile together all the classes connected to | each | | > others, like this. | | > PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e | | > 'Rcpp:::LdFlags()'` R CMD SHLIB ClassFive.cpp ClassOne.cpp ClassTwo.cpp | | > ClassThree.cpp ClassFour.cpp | | > | | > When I finally compiled my real code, I didn't get any compilation | error, | | > but I still got from within R the error message: | | > Error in dyn.load("ClassFive.so") : | | > unable to load shared object [...] | | > Symbol not found: __ZN3re23RE23Arg11parse_floatEPKciPv | | > | | > I checked for the issues that generated the same problem before, i.e. | | > constructor and deconstructors, and they are all ok. | | > I couldn't find any explicit call to "parse_float" which seems to be | | > reported in the error message. | | > To start, I linked only one class to R and one method only of the very | same | | > class. | | > | | > I understand it might be quite difficult to identify the specific | problem | | > without going through lots of code (I have now 5 different classes, | each | | > with several methods). | | > Is there a number of possible mistakes leading to such kind of | messages, | | > that could help me narrow down the cause? | | > | | > Thanks very much for any help, | | > Francesco | | > | | > | | > ------------ | | >> sessionInfo() | | > R version 2.15.1 (2012-06-22) | | > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) | | > | | > locale: | | > [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 | | > | | > attached base packages: | | > [1] stats graphics grDevices utils datasets methods base | | > | | > other attached packages: | | > [1] inline_0.3.8 Rcpp_0.9.13 | | > | | > loaded via a namespace (and not attached): | | > [1] tcltk_2.15.1 tools_2.15.1 | | > | | > | | > | | > | | > On 6 Jul 2012, at 15:50, Lescai, Francesco wrote: | | > | | > Argh.. Apologies guys.. Found the error myself. | | > Constructor and deconstructor must be specified with {} even if no code | is | | > foreseen for them. | | > | | > A novice error, hope at least highlighting it could be useful to other | | > newbies like me :-) | | > | | > cheers, | | > Francesco | | > | | > | | > On 6 Jul 2012, at 15:37, Lescai, Francesco wrote: | | > | | > Hi there, | | > | | > I've seen other posts similar to this one, but I'm a complete novice in | the | | > use of Rcpp and couldn't really figure out how to solve the issue. | | > | | > | | > I'm learning how to use Rcpp before connecting R to some C++ classes | I'm | | > developing. | | > | | > I started with a simple home made example, but in both cases compiling | .cpp | | > and header files or compiling inline code, I get the same outcome error | | > "unable to load shared object" and then "Symbol not found" with some | | > characters before and after my class name. | | > | | > | | > I've seen Mac OS might have some issues, therefore I tested it also on | an | | > Ubuntu virtual machine, but the result is the same error message. | | > | | > Also, I'm using an R-devel version here but I'm having the same problem | with | | > R 14 as well. | | > | | > I'll copy below all the relevant information (bit lengthy, I'm sorry). | | > | | > | | > I'd really appreciate some help here to point me in the right | direction. | | > | | > thanks very much, | | > | | > Francesco | | > | | > | | > | | > ------case 1 - external files ------------------- | | > | | > | | > PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e | | > 'Rcpp:::LdFlags()'` R CMD SHLIB example.cpp | | > | | > g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include | | > -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG | | > -I/Library/Frameworks/R.framework/Versions/2.16/Resources/library/Rcpp/ | include | | > -I/usr/local/include -fPIC -g -O2 -c example.cpp -o example.o | | > | | > g++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names | -undefined | | > dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/ | lib -o | | > example.so example.o | | > /Library/Frameworks/R.framework/Versions/2.16/Resources/library/Rcpp/ | lib/x86_64/libRcpp.a | | > -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework | | > -Wl,CoreFoundation | | > | | > | | > library(Rcpp) | | > | | > library(inline) | | > | | > dyn.load("example.so") | | > | | > Error in dyn.load("example.so") : | | > | | > unable to load shared object | | > '/Users/rehbfle/Documents/CPPexercise/RCPP/example.so': | | > | | > dlopen(/Users/rehbfle/Documents/CPPexercise/RCPP/example.so, 6): Symbol | not | | > found: __ZN7exampleD1Ev | | > | | > Referenced from: /Users/rehbfle/Documents/CPPexercise/RCPP/example.so | | > | | > Expected in: flat namespace | | > | | > in /Users/rehbfle/Documents/CPPexercise/RCPP/example.so | | > | | > | | > | | > ---------case 2 - inline code----------------------------------------- | | > | | > | | > fx<-cxxfunction(signature(), plugin="Rcpp", include=inc) | | > | | > Error in dyn.load(libLFile) : | | > | | > unable to load shared object | | > '/var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/ | file34b510aaf8e3.so': | | > | | > dlopen(/var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/ | file34b510aaf8e3.so, | | > 6): Symbol not found: __ZN7exampleC1Eii | | > | | > Referenced from: | | > /var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/ | file34b510aaf8e3.so | | > | | > Expected in: flat namespace | | > | | > in | | > /var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/ | file34b510aaf8e3.so | | > | | > | | > | | > Below the code details: | | > | | > | | > example.h | | > | | > ------------------------- | | > | | > #ifndef EXAMPLE_H | | > | | > #define EXAMPLE_H | | > | | > | | > class example | | > | | > { | | > | | > | | > private: | | > | | > float resultone; | | > | | > int resultwo; | | > | | > public: | | > | | > example(int x, int y); | | > | | > ~example(); | | > | | > float multiply(int x, int y); | | > | | > int doublex(int x); | | > | | > | | > }; | | > | | > | | > | | > #endif | | > | | > | | > | | > example.cpp | | > | | > --------------------------- | | > | | > #include "example.h" | | > | | > #include <Rcpp.h> | | > | | > | | > using namespace Rcpp; | | > | | > | | > example::example(int x, int y){} | | > | | > | | > float example::multiply(int x, int y){ | | > | | > resultone = x * y; | | > | | > return resultone; | | > | | > } | | > | | > | | > int example::doublex(int x){ | | > | | > resultwo = x * 2; | | > | | > return resultwo; | | > | | > } | | > | | > | | > RCPP_MODULE(prova){ | | > | | > | | > class_<example>("example") | | > | | > .constructor<int,int>() | | > | | > .method("square", &example::multiply) | | > | | > .method("doppio", &example::doublex) | | > | | > ; | | > | | > } | | > | | > | | > | | > ----------inline code---------------- | | > | | > inc <-'using namespace Rcpp; | | > | | > class example | | > | | > { | | > | | > private: | | > | | > float resultone; | | > | | > int resultwo; | | > | | > | | > public: | | > | | > example(int x, int y); | | > | | > ~example(); | | > | | > float multiply(int x, int y){ | | > | | > resultone = x * y; | | > | | > return resultone; | | > | | > } | | > | | > int doublex(int x){ | | > | | > resultwo = x * 2; | | > | | > return resultwo; | | > | | > } | | > | | > | | > }; | | > | | > | | > RCPP_MODULE(prova){ | | > | | > | | > class_<example>("example") | | > | | > .constructor<int,int>() | | > | | > .method("square", &example::multiply) | | > | | > .method("doppio", &example::doublex) | | > | | > ; | | > | | > }' | | > | | > | | > | | > ----------------- | | > | | > sessionInfo() | | > | | > R Under development (unstable) (2012-07-02 r59715) | | > | | > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) | | > | | > | | > locale: | | > | | > [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 | | > | | > | | > attached base packages: | | > | | > [1] stats graphics grDevices utils datasets methods base | | > | | > | | > other attached packages: | | > | | > [1] inline_0.3.8 Rcpp_0.9.13 | | > | | > | | > | | > | | > | | > | | > | | > _______________________________________________ | | > | | > Rcpp-devel mailing list | | > | | > [email protected] | | > | | > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | | > | | > | | > | | > | | > | | > _______________________________________________ | | > Rcpp-devel mailing list | | > [email protected] | | > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | | > | | > | | > | --------------------------------------------------------------------------------- | | > Francesco Lescai, PhD, EDBT | | > Senior Research Associate in Genome Analysis | | > University College London | | > Faculty of Population Health Sciences | | > Dept. Genes, Development & Disease | | > ICH - Molecular Medicine Unit, GOSgene team | | > 30 Guilford Street | | > WC1N 1EH London UK | | > | | > email: [email protected] | | > phone: +44.(0)207.905.2274 | | > [ext: 2274] | | > | -------------------------------------------------------------------------------- | | > | | > | | > _______________________________________________ | | > Rcpp-devel mailing list | | > [email protected] | | > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | | _______________________________________________ | | 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 | | | | --------------------------------------------------------------------------------- | Francesco Lescai, PhD, EDBT | Senior Research Associate in Genome Analysis | University College London | Faculty of Population Health Sciences | Dept. Genes, Development & Disease | ICH - Molecular Medicine Unit, GOSgene team | 30 Guilford Street | WC1N 1EH London UK | | email: [email protected] | phone: +44.(0)207.905.2274 | [ext: 2274] | -------------------------------------------------------------------------------- | -- 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
