当我试图编译Armadillo 2.4.2附带的example1.cpp时,我一直得到以下链接错误:
/tmp/ccbnLbA0.o: In function `double arma::blas::dot<double>(unsigned int, double const*, double const*)':
main.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[double arma::blas::dot<double>(unsigned int, double const*, double const*)]+0x3b): undefined reference to `wrapper_ddot_'
/tmp/ccbnLbA0.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
main.cpp:(.text._ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_[void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)]+0x68): undefined reference to `wrapper_dgemv_'
/tmp/ccbnLbA0.o: In function `void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
main.cpp:(.text._ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_[void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)]+0x7a): undefined reference to `wrapper_dgemm_'
collect2: ld returned 1 exit status有人能帮忙吗?我手动安装
BLAS
我在MacBook Pro 7,1模型上使用Ubuntu11.04
发布于 2012-01-25 19:13:38
非常感谢osgx!在阅读了他的评论后,我再次查看了自述文件!原来我在命令中漏掉了'-O1 -larmadillo‘!
下面是我用来让它正常工作的命令:
g++ example1.cpp -o example1 -O1 -larmadillo愚蠢的错误,我知道..。它只是提醒你阅读自述文件是多么的重要。
自述机构还提到:
如果您获得链接错误,或者Armadillo是手动安装的,并且指定了LAPACK和BLAS可用,则需要显式地链接到LAPACK和BLAS (或它们的对等程序),例如:
g++ example1.cpp -o example1 -O1 -llapack -lblas我不需要包括'-llapack -lblas‘,但是这可能会帮助其他有类似问题的人。
发布于 2017-04-23 20:40:20
有一个奇怪的问题,我刚刚发现,通过比较以前工作的代码编译与这个线程的问题,强调涉及的gnu (我不是专家在这方面):在我的机器编译成功取决于参数的顺序gcc/g++,其中g++ infile -o外文件-libarmadillo .工作过,但是g++ -libarmadillo infile -o .没有(几乎)与上面提到的相同的错误。(希望这有帮助)。
https://stackoverflow.com/questions/8978742
复制相似问题