我正在按照these的说明,在我的10.13.6 High Sierra mac上安装Rstan,具有3.5.1'Feather Spray'R版本和1.1.419 Rstudio版本。
由于macOS R工具链安装程序在安装过程中始终出现错误,因此我选择了here中所述的手动步骤。
在我的第一次尝试中,我只是更新了Xcode并按照说明进行了操作,但由于这似乎不起作用,我删除了Xcode(也按照建议的here从bin中删除了),然后重新安装了Xcode 10.1(10B61),并按照here中所述在终端中运行'sudo xcodebuild -license'接受了许可证。
命令行工具似乎可以运行
> system('clang++ -v')
提供以下输出:
Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target:
x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
在下一步中,我运行了用于配置clang ++的代码块,然后运行此行:
# print the contents to the console
> cat(readLines(MAKEVARS), sep = "\n")
导致以下结果:
LDFLAGS= -L/usr/local/clang4/lib # The following statement changes
the Fortran linking path
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 #
End Fortran linking path statement # The following statement changes
the Fortran linking path
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 #
End Fortran linking path statement CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++ CXX1X=/usr/local/clang4/bin/clang++
CXX98=/usr/local/clang4/bin/clang++
CXX11=/usr/local/clang4/bin/clang++
CXX14=/usr/local/clang4/bin/clang++
CXX17=/usr/local/clang4/bin/clang++ # The following statement
changes the Fortran linking path
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 #
End Fortran linking path statement
CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable
-Wno-unused-function -Wno-unknown-pragmas CC=clang CXX14=clang++ -arch x86_64 -ftemplate-depth-256
CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable
-Wno-unused-function -Wno-unknown-pragmas CC=clang CXX14=clang++ -arch x86_64 -ftemplate-depth-256
接下来,按照说明安装pkgbuild软件包,然后执行以下说明:
pkgbuild::has_build_tools(debug = TRUE)
要检查pkgbuild认为您的工具链正在运行。它还指出:
如果返回FALSE,则返回上一部分,然后 正确安装工具链。
在运行该行时,Rstudio提示我:
从源代码构建R软件包需要安装其他组件 构建工具。您是否要立即安装其他工具?
如果在是否要安装其他工具的问题上单击“否”,则R返回:
[1] FALSE
如果单击“是”,我将到达this页面。我已经按照该页面上的说明从Apple的开发人员页面下载并安装了命令行工具(提到了第二个选项),这没有什么区别,并且我仍然建议在检查pkgbuild行时需要其他构建工具。尝试通过终端运行:
xcode-select --install
结果:
error: command line tools are already installed, use "Software Update"
to install updates
但是,我的应用商店中没有软件更新。
如果我继续执行说明的下一步(因此可以忽略pkgbuild错误):
> fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
+ ' )
我得到以下输出:
/Library/Frameworks/R.framework/Resources/bin/R: line 142:
/Library/Frameworks/R.framework/Resources/etc/x86_64/ldpaths: No such
file or directory
ERROR(s) during compilation: source code errors or compiler
configuration errors!
Program source: 1: 2: // includes from the plugin 3: #include
<R.h> 4: #include <Rdefines.h> 5: #include <R_ext/Error.h> 6:
7: 8: // user includes 9: 10: 11: // declarations 12: extern
"C" { 13: SEXP file758212ccc99c( SEXP x, SEXP y) ; 14: } 15: 16:
// definition 17: 18: SEXP file758212ccc99c( SEXP x, SEXP y ){ 19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ; 21:
22: Rf_warning("your C++ program does not return anything"); 23:
return R_NilValue ; 24: } 25: 26: Error in compileCode(f, code,
language = language, verbose = verbose) : Compilation ERROR,
function(s)/method(s) not created!
/Library/Frameworks/R.framework/Resources/bin/R: line 142:
/Library/Frameworks/R.framework/Resources/etc/x86_64/ldpaths: No such
file or directory In addition: Warning message: In system(cmd, intern
= !verbose) : running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB
file758212ccc99c.cpp 2> file758212ccc99c.cpp.err.txt' had status 1
这使我认为Rtools的路径可能有问题吗?如果我做错了明显的事,我表示歉意,但是在此过程的此阶段(pkgbuild check)中找不到以前的问题的输入,我将非常感激我接下来可以尝试的任何输入!如果我只想从笔记本电脑中取出所有物品,我也很乐意为您提供建议,以确保这些失败尝试中的所有物品尽可能消失。