xcode – RcppArmadillo在OS X Mavericks上编译错误
这是
Element-Wise Matrix Multiplication in Rcpp问题的后续行动
自升级到小牛队以来,我一直在使用RcppArmadillo获得许多不同类型的错误.我安装了Xcode 5.0.2和命令行工具.另外,来自Homebrew的gfortran.但我一直遇到以下错误 – > cppFunction("arma::mat schur(arma::mat& a,arma::mat& b) { return(a % b); }",depends="RcppArmadillo") ld: library not found for -lgfortran clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [sourceCpp_18474.so] Error 1 clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include - I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RcppArmadillo/include" -fPIC "-mtune=native -g -O2 -Wall -pedantic -Wconversion" -c fileaf992bfb8f84.cpp -o fileaf992bfb8f84.o clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o sourceCpp_18474.so fileaf992bfb8f84.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -lgfortran /Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/lib/libRcpp.a -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation Error in sourceCpp(code = code,env = env,rebuild = rebuild,showOutput = showOutput,: Error 1 occurred building shared library. WARNING: The tools required to build C++ code for R were not found. Please install Command Line Tools for XCode (or equivalent). # Contents of Makevars $cat ~/.R/Makevars CC=clang CXX=clang++ CXXFLAGS="-mtune=native -g -O2 -Wall -pedantic -Wconversion" FLIBS=-lgfortran 评论FLIBS = -lgfortran没有帮助,导致更多错误消息 – > cppFunction("arma::mat schur(arma::mat& a,arma::mat& b) { return(a % b); }",depends="RcppArmadillo") ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64' ld: warning: directory not found for option '-L/usr/local/lib/x86_64' ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3' ld: library not found for -lgfortran clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [sourceCpp_50381.so] Error 1 提前致谢. 更新 根据以下Kevin和Dirk的回复建议,我重新安装了Rcpp,RcppArmadillo并从源代码内联并更新了FLIBS以指向实际目录.这解决了这个问题. # Update FLIBS in ~/.R/Makevars FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran #Re-Install from source install.packages(c("Rcpp","RcppArmadillo","inline"),type="source") #Restart R 解决方法
编辑:如果你是一个Homebrew用户,你现在需要使用brew install gcc(gfortran不再单独提供gcc),然后你可以按照
here的说明进行设置.
您必须手动将库符号链接到/usr/local / lib: ln -s /usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.* /usr/local / lib / 我以为brew链接gfortran会处理这个,但显然它只是符号链接gfortran程序而不是实际的库.所以,不幸的是,你必须自己做. (将4.8.2替换为您在自制软件中使用的任何版本的gfortran.) 或者,如果您想继续修改/usr/local / lib,则可以使用 FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran 在你的?/ .R / Makevars文件中,所以R知道在哪里可以找到gfortran库. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |