我试图构建一个具有RcppArmadillo代码的软件包,但始终遇到编译错误。为简单起见,我开始时未添加自己的代码。我第一次尝试
library(Rcpp)
Rcpp.package.skeleton("test")
我运行“ R CMD检查测试”,没有错误返回。然后,我对RcppArmadillo命令执行了相同的操作,如下所示:
library(Rcpp)
Rcpp.package.skeleton("test1")
当我从命令行运行“ R CMD check test1”时,出现如下错误消息:
...
* checking whether package ‘test1’ can be installed ... ERROR
Installation failed.
...
我进一步检查了00install.out文件,它显示为
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’
任何人都对“错误:不支持的选项'-fopenmp'make” 有任何想法吗?该如何解决?
谢谢!
更新:我按照网站上的说明进行了以下操作: 1.更新xcode 2. brew安装llvm 3.从cran下载并安装gcc和clang 8 4.创建〜/ R目录并创建文件Makevars,如下所示:
# 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
/bin/sh: XX: command not found
make: *** [RcppExports.o] Error 127
对新错误有任何帮助吗?它是什么?谢谢!