Reputation: 1290
I have an R package with a list of imports and have never had a problem loading the latest version. I have just added data.table
to the list, and now cannot load the package.
OS : macOS Sierra 10.12.5/6
gcc :
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
Imports
aws.s3,
data.table,
googledrive,
httr,
jsonlite,
lubridate,
plyr
RMixpanel,
rmongodb,
RPresto,
stringi,
stringr,
uuid
Errors
openmp-utils.c:50:5: warning: implicit declaration of function 'omp_set_num_threads' is invalid in C99 [-Wimplicit-function-declaration]
omp_set_num_threads(1);
^
1 warning generated.
...
Error: package or namespace load failed for ‘data.table’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/3.4/site-library/data.table/libs/datatable.so':
dlopen(/usr/local/lib/R/3.4/site-library/data.table/libs/datatable.so, 6): Symbol not found: _omp_set_num_threads
Referenced from: /usr/local/lib/R/3.4/site-library/data.table/libs/datatable.so
Expected in: flat namespace in /usr/local/lib/R/3.4/site-library/data.table/libs/datatable.so
Error: loading failed
I have also tried moving plyr
to be higher than data.table
, but get the same error. Any ideas for anything I'm missing?
Upvotes: 4
Views: 565
Reputation: 59612
I fixed my mistake and pushed 1.10.4-2 to CRAN.
- OpenMP on MacOS is now supported by CRAN and included in CRAN’s package binaries for Mac. But installing v1.10.4-1 from source on MacOS failed when OpenMP was not enabled at compile time, #2409. Thanks to Liz Macfie and @fupangpangpang for reporting. The startup message when OpenMP is not enabled has been updated.
I've added an extra step to the release procedures to prevent this happening in future.
Upvotes: 3
Reputation: 9666
I had the same issue yesterday and after some googling I managed to install data.table
by specifying ~./R/Makevars.
In my case I used macports and installed gcc7. Which under macports are referenced by gcc-mp-7 and g++-mp-7
So to specify the compiler to use these instead of the default clang on macOS you need to create a file ~./R/Makevars . Then add the following lines:
CC=gcc-mp-7 -fopenmp
CXX=g++-mp-7 -fopenmp
You should also be able to do the same with newer versions of clang
just change the gcc-mp-7
to clang-omp
(or something equivalent depending on where it's installed) and don't forget the same -fopenmp
flag in order to enable multi threading.
Upvotes: 2