I tried to build a package that has RcppArmadillo codes, but always had encountered compilation errors. To be simple, I started without adding my own codes. I firs tried
library(Rcpp)
Rcpp.package.skeleton("test")
I run "R CMD check test", and no errors returned. I then did the same thing for RcppArmadillo command as follows:
library(Rcpp)
Rcpp.package.skeleton("test1")
When I run "R CMD check test1" from command line, then I got an error message as follows:
...
* checking whether package ‘test1’ can be installed ... ERROR
Installation failed.
...
I further checked the 00install.out file, it says
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/RcppArmadillo/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fopenmp -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang: error: unsupported option '-fopenmp'
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘test1’
Anyone has any idea on "error: unsupported option '-fopenmp' make"? how to fix it?
Thanks in advance!
Update: I followed the instruction from website and did the following: 1. update xcode 2. brew install llvm 3. download gcc and clang 8 from cran and installed 4. created ~/R directory and created a file Makevars as follows:
# The following statements are required to use the clang8 binary
CC=/usr/local/clang8/bin/clang
CXX=/usr/local/clang8/bin/clang++
CXX11=$CXX
CXX14=$CXX
CXX17=$CXX
CXX1X=$CXX
LDFLAGS=-L/usr/local/clang8/lib
# End clang8 inclusion statements
- I created test1 package (again without adding my R codes or RcppArmadillo codes). Run R CMD check test1. The Clang error is gone, but I got the new errors:
/bin/sh: XX: command not found
make: *** [RcppExports.o] Error 127
Any help on the new error? what is it? thanks!