Linker 犰狳+;BLAS+;链接错误?

Linker 犰狳+;BLAS+;链接错误?,linker,lapack,blas,armadillo,Linker,Lapack,Blas,Armadillo,当我试图编译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>(

当我试图编译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
/tmp/ccbnLbA0.o:double arma::blas::dot(无符号整数,双常量*,双常量*)函数中:
main.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[double arma::blas::dot(unsigned int,double const*,double const*)]+0x3b):对“wrapper\u ddot”的未定义引用
/tmp/ccbnLbA0.o:在函数“void arma::blas::gemv(char-const*、int-const*、int-const*、double-const*、double-const*、int-const*、double-const*、int-const*)中:
main.cpp:(.text._zn4arma4blas4Gemvideevpkckpkis5_PKT_S8_S8_S5_PS6_S5[void arma::blas::gemv(char const*、int const*、double const*、double const*、double const*、double const*、int const*、double const*)+0x68):未定义的“包装器”参考
/tmp/ccbnLbA0.o:在函数“void arma::blas::gemm(char const*、char const*、int const*、int const*、int const*、double const*、double const*、int const*、double const*、int const*、double const*、int const*)中:
main.cpp:(.text."zn4arma4blas4gemmedievpkcs3"PKiS5"u PKT"u S8"u S8"S8"PS6"[void arma::blas::gemm(char const*,char const*,int const*,int const*,int const*,double const*,double const*,int const*,int const*)]
collect2:ld返回了1个退出状态
有人能帮忙吗?我手动安装

  • BLAS的最新版本
  • lapack-3.4.0
  • boost-1.48.0
  • ATLAS的最新版本

我在MacBookPro 7,1机型上使用Ubuntu 11.04

非常感谢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',但这可能会帮助其他有类似问题的人。

从5.0.0开始(可能也适用于早期版本)


实际上,你需要
-larmadillo
,在Fedora 21上
-llapack
-lopenblas
不再是不必要的了。

我刚刚发现了一个奇怪之处,将以前的代码编译与这个线程的问题进行比较,强调gnu cc的参与(我在这方面不是专家):在我的机器上编译成功与否取决于gcc/g++中参数的顺序,其中 g++infie-o outfile-libarmadillo。。。成功了,但是 g++-libarmadillo infie-o输出文件。。。没有(几乎)与上述相同的错误。
(希望有帮助)。

看起来您的犰狳没有正确配置,或者编译字符串中没有提到所需的库。你能展示一下你是如何编译example1.cpp的吗?这正是我想要的!必须仅链接LAPACK和BLAS。我也为没有阅读自述感到内疚,所以不要难过。我在交叉编译,并得到了对我的LAPACK和BLAS的未定义引用:
“cgemv”;“sdot”
,…等等。。。