[Rcpp-devel] Getting different build commands on Linux vs. Mac OS
Evan Biederstedt
evan.biederstedt at gmail.com
Mon Apr 30 21:01:19 CEST 2018
Hi all
Thank you for the responses.
@Keith
> 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.
Yes, it's odd.
@Dirk
> Are the libraries installed on the macOS box?
When I build bamdb, CMake checks for the required, which corresponds to
what I see
https://github.com/d-lo/bamdb
```
-- Detecting CXX compile features - done
-- Found CK
-- Found ZLIB: /usr/local/lib/libz.dylib (found version "1.2.11")
-- Found HTSlib
-- Found LMDB
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ebiederstedt/bamdb/build
```
With `sudo make install`, I think `bamdb` should be accessible via `-lbamdb`
```
$ sudo make install
Password:
[ 50%] Built target bamdb
[100%] Built target libbamdb
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/bamdb
-- Up-to-date: /usr/local/include/bamdb
-- Up-to-date: /usr/local/include/bamdb/bam_api.h
-- Up-to-date: /usr/local/include/bamdb/bam_lmdb.h
-- Up-to-date: /usr/local/include/bamdb/bamdb.h
-- Installing: /usr/local/lib/libbamdb.dylib
```
It's very odd these PKG_LIBS are ignored though....
> Could you compile and link a trivial test program against them?
I think this is the next step...
@Ralf
> You can change the used compiler for *your* system via ~/.R/Makevars,
though. From my point of view that is a (short-time) workaround only. You
have to figure out why clang does not like your package/library.
I've yet to test changing the compiler in ~/.R/Makevars. However, it's not
clear to me why this would be a short-term solution. Could you clarify why
using g++ instead of clang would be a problem gong forwards?
On Mon, Apr 30, 2018 at 11:27 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 30 April 2018 at 06:48, Evan Biederstedt 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
>
> Ok, so src/Makevars wants three libraries:
>
> PKG_LIBS= -lbamdb -llmdb -lhts
>
> |
> | 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
>
> and here we get them as libbamdb.so, liblmdb.so, libhts.so are all system
> level libraries and (I guess) 'sudo ldconfig -p' shows them. Linking works,
> and they are found as the package loads.
>
> | 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
>
> I think they should show up here too, but they do not.
>
> Are the libraries installed on the macOS box? Could you compile and link a
> trivial test program against them?
>
> Dirk
>
>
> | 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
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20180430/8c8f2df5/attachment-0001.html>
More information about the Rcpp-devel
mailing list