iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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, arm
这是 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库.

大佬总结

以上是大佬教程为你收集整理的xcode – RcppArmadillo在OS X Mavericks上编译错误全部内容,希望文章能够帮你解决xcode – RcppArmadillo在OS X Mavericks上编译错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。