Search code examples
rmacosinstallationclangrcpp

error in dyn.load in Rcpp package in mac


I have a problem in loading compiled object Rcpp compiled object. I am compiling RcppSMC package from source. I

Error in dyn.load("mylib.so") : 
  unable to load shared object '/Users/avi/softwares/RcppSMC/src/mylib.so': 
  dlopen(/Users/avi/softwares/RcppSMC/src/mylib.so, 6): Symbol not found: __ZNSoD0Ev
  Referenced from: /Users/avi/softwares/RcppSMC/src/mylib.so
  Expected in: flat namespace
 in /Users/avi/softwares/RcppSMC/src/mylib.so 

I am using clang for compiling with following verson. I think there is some compiling problem because if I download the mac os binary from CRAN dyn.load works.

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0 

clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include -I/usr/local/include -I"/Users/avi/Library/R/3.0/library/Rcpp/include"   -fPIC  -g -O3 -pipe -std=c++0x -Wall -pedantic -c blockpfgaussianopt.cpp -o blockpfgaussianopt.o
  .....
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o mylib.so blockpfgaussianopt.o history.o pflineart.o pfnonlinbs.o smc-exception.o /Users/avi/Library/R/3.0/library/Rcpp/lib/libRcpp.a -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation

installing to /Users/avi/Library/R/3.0/library/RcppSMC/libs

This is weird problem because sourceCpp is working in the machine.


Solution

  • If you're trying to install a package that links to Rcpp from source, you probably also need to install Rcpp from source.

    Assuming that you're using OS X Mavericks, there have been similar posts around StackOverflow with similar problems.