尝试从github安装R fst软件包的开发版时出现“/ bin / sh:XX:command not found”错误

我正在尝试从
github安装
fst package的开发版本. (我想要开发版本,因为它在保存数据帧时维护列类,而当前发布的版本则没有.)

最初,由于缺少OpenMP支持,安装失败.我按照OSX上R 3.4.0的步骤here解决了这个问题(我认为).

但是,现在我收到以下错误:/ bin / sh:XX:找不到命令.我已经设置了〜/ .R / Makevars文件中应该是合适的路径,所以我不知道接下来要做什么来解决错误.

这是我的代码和输出:

在添加OpenMP支持之前,首先尝试安装fst

devtools::install_github("fstPackage/fst", ref = "develop")

* installing *source* package ‘fst’ …
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -fopenmp -I. -Ifstcore -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common -Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress -I”/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include”
-I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include -fPIC -Wall -g -O2 -c FastStore.cpp -o FastStore.o
clang: error: unsupported option ‘-fopenmp’
make: *** [FastStore.o] Error 1
ERROR: compilation failed for package ‘fst’

添加OpenMP支持

为了添加OpenMP支持,我按照R00.3.0的步骤here进行了操作,包括从here安装gfortran 6.1并使用here提供的预构建的OSX GUI安装程序进行clang.然后,按照说明,我将以下内容添加到〜/ .R中/ Makevars文件:

CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++
CXX11=$CXX
CXX14=$CXX
CXX17=$CXX
CXX1X=$CXX
LDFLAGS=-L/usr/local/clang4/lib

第二次尝试安装fst

然后我再次运行安装代码并收到以下错误:

devtools::install_github("fstPackage/fst", ref = "develop")

* installing *source* package ‘fst’ …
** libs
XX -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -fopenmp -I. -Ifstcore -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common -Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress -I”/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include”
-I/usr/local/include -fPIC -Wall -g -O2 -c FastStore.cpp -o FastStore.o
/bin/sh: XX: command not found
make: *** [FastStore.o]
Error 127 ERROR: compilation failed for package ‘fst’

除了错误之外,我可以看到安装输出在第一次尝试时以clang -std = gnu 11 …开始,在第二次尝试时以XX -std = gnu 11 …开始.我猜我需要告诉R(或其他一些程序)关于clang的路径,但我不确定需要什么路径或把它放在哪里(并且不是Makevars文件应该处理它?),或者是否还有其他问题需要修复.

以下是我的系统的一些细节:

Macbook Pro,OSX Sierra(版本10.12.5)

RStudio版本1.0.153

R会话信息

R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] httr_1.2.1      compiler_3.4.1  R6_2.2.2        tools_3.4.1     withr_1.0.2    
 [6] curl_2.8.1      memoise_1.1.0   git2r_0.19.0    digest_0.6.12   devtools_1.13.2

更新:基于@MarkPlotnick的评论,我将Makevars更改为以下内容:

CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++
CXX11=$(CXX)
CXX14=$(CXX)
CXX17=$(CXX)
CXX1X=$(CXX)
LDFLAGS=-L/usr/local/clang4/lib

这导致以下错误:

* installing source package ‘fst’ …
** libs /Users/eipi10/.R/Makevars:7: *** Recursive variable `CXX’ references itself (eventually). Stop.
ERROR: compilation failed for package ‘fst’

最佳答案 我遇到了这个问题并根据@Dirk在
“/bin/sh: XX: command not found” error when trying to install development version of R fst package from github的评论找出了解决方案

我在.R / Makevars中明确设置了库:

CXX11=/usr/local/clang4/bin/clang++
CXX14=/usr/local/clang4/bin/clang++
CXX17=/usr/local/clang4/bin/clang++
CXX1X=/usr/local/clang4/bin/clang++

当我遇到这个问题时,这对我有用,虽然在我的Mac上,二进制文件的路径是/ Library / Developer / CommandLineTools /usr/bin/clang)

点赞