我写了一个使用RcppArmadillo的小包装。它在Linux和Windows上可以正常编译,但在MacOS上不能编译。错误是:
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppArmadillo/include" -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 ‘ed0’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/ed0’
Error in i.p(...) :
(converted from warning) installation of package ‘/var/folders/ql/j3z8hyt927jfqhs4v836c6580000gn/T//RtmpOmkBP8/file4403a3bb5ec/ed0_0.1.0.tar.gz’ had non-zero exit status
我的Makevars如下(即由RcppArmadillo自动生成)
## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here. It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
我在Google周围搜索,但找不到解决方法。