[Rcpp-devel] Getting different build commands on Linux vs. Mac OS

Keith O'Hara kth.ohr at gmail.com
Mon Apr 30 16:34:48 CEST 2018


Looks like your PKG_LIBS arguments are ignored/overwritten on the Mac build; ‘bambi.so’ appears to be missing objects contained in -lbamdb, hence the load error.

Keith

> On Apr 30, 2018, at 6:48 AM, Evan Biederstedt <evan.biederstedt at gmail.com> wrote:
> 
> Dear list
> 
> I have the following R package which is interacting with a C library via Rcpp and extern. At some point, the goal is to combine these....but I'm trying this with baby steps.
> 
> R package with C++ wrapper:
> https://github.com/d-lo/bambi
> 
> The C library:
> https://github.com/d-lo/bamdb
> 
> When I try to install the R package on Linux, the Makevars appears use the compiler g++, and it installs correctly:
> 
> 
> ```
> Installing package into '/home/username/R/x86_64-pc-linux-gnu-library/3.2'
> (as 'lib' is unspecified)
> * installing *source* package 'bambi' ...
> ** libs
> g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/  -I"/usr/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
> g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/  -I"/usr/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bambi.cpp -o bambi.o
> g++ -std=c++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o bambi.so RcppExports.o bambi.o -lbamdb -llmdb -lhts -L/usr/lib/R/lib -lR
> installing to /home/username/R/x86_64-pc-linux-gnu-library/3.2/bambi/libs
> ** R
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
> * DONE (bambi)
> > library(bambi)
> ```
> 
> Here's what I see when I do the same on Mac OS. It uses clang++, and has entirely different build commands:
> 
> ```
> * installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
> * installing *source* package ‘bambi’ ...
> ** libs
> clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
> clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c bambi.cpp -o bambi.o
> clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c rcpp_hello_world.cpp -o rcpp_hello_world.o
> clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o bambi.so RcppExports.o bambi.o rcpp_hello_world.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
> installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs
> ** R
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
> Error: package or namespace load failed for ‘bambi’ in dyn.load(file, DLLpath = DLLpath, ...):
>  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so':
>   dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so, 6): Symbol not found: _get_bam_rows
>   Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so
>   Expected in: flat namespace
>  in /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so
> Error: loading failed
> Execution halted
> ERROR: loading failed
> * removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi’
> 
> ```
> 
> Why is there this discrepancy? How do I direct the Makevars to use g++ and give me the "correct" build as I see on Linux? `CXX=g++` or `CXX=/usr/local/bin/g++` doesn't appear to work. 
> 
> 
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel



More information about the Rcpp-devel mailing list