Skip to content

Problems building/loading package using rTRNG under macOS #13

@richfitz

Description

@richfitz

I am trying to use rTRNG within a package and hitting an issue with the linking. Following #8 (which is probably the same underlying issue) have have created a basic skeleton following your instructions, which is here: https://github.com/richfitz/pkgUsingTRNG (unchanged from the result of running the demo script).

This appears to build, but does not load for me on macOS with the error:

$ R CMD INSTALL pkgUsingTRNG
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library’
* installing *source* package ‘pkgUsingTRNG’ ...
** using staged installation
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rTRNG/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rTRNG/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c trng_hello_world.cpp -o trng_hello_world.o
clang++ -std=gnu++11 -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 pkgUsingTRNG.so RcppExports.o trng_hello_world.o /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rTRNG/libs/rTRNG.so -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-pkgUsingTRNG/00new/pkgUsingTRNG/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘pkgUsingTRNG’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-pkgUsingTRNG/00new/pkgUsingTRNG/libs/pkgUsingTRNG.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-pkgUsingTRNG/00new/pkgUsingTRNG/libs/pkgUsingTRNG.so, 6): Library not loaded: rTRNG.so
  Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-pkgUsingTRNG/00new/pkgUsingTRNG/libs/pkgUsingTRNG.so
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/pkgUsingTRNG’

(this is on R 3.6.1 on macOS 10.14.6 using the CRAN version of rTRNG)

In contrast this works fine on ubuntu (tested via docker using rocker/r-ver:4.0.0):

# R CMD INSTALL pkgUsingTRNG
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘pkgUsingTRNG’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/local/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/rTRNG/include' -I/usr/local/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=gnu++11 -I"/usr/local/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/rTRNG/include' -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c trng_hello_world.cpp -o trng_hello_world.o
g++ -std=gnu++11 -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o pkgUsingTRNG.so RcppExports.o trng_hello_world.o /usr/local/lib/R/site-library/rTRNG/libs/rTRNG.so -L/usr/local/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-pkgUsingTRNG/00new/pkgUsingTRNG/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (pkgUsingTRNG)

I have not yet tested this on windows.

Do you have any ideas as to why this might not work? Has this been found to work on macOS previously?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions