2012-01-23 46 views
4

当我尝试编译自带的犰狳2.4.2 example1.cpp,我不断收到以下错误链接:Armadillo + BLAS + LAPACK:链接错误?

/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的最新版本
  • LAPACK-3.4.0
  • 升压1.48.0
  • 最新版本ATLAS

我使用Ubuntu 11.04上MacBook Pro 7,1型号

+1

看起来你的Armadillo配置不正确,或者编译字符串中没有提到需要的库。你可以显示,你如何编译example1.cpp – osgx

回答

14

非常感谢osgx!阅读他的评论后,我再看看README文件!原来我在命令中错过了'-O1 -larmadillo'!

下面是我用得到它的工作命令:

g++ example1.cpp -o example1 -O1 -larmadillo 

愚蠢的错误,我知道....它只是提醒你它是多么的重要阅读README。

自述也提到:

如果你得到链接错误,或者如果犰狳手动 安装,您指定的LAPACK和BLAS,则您将 需要明确与LAPACK和BLAS(或他们的链接当量), 例如:

g++ example1.cpp -o example1 -O1 -llapack -lblas 

我没有包括“-llapack -lblas”但也许这将帮助其他人谁是有类似的问题。

+0

这正是我一直在寻找的!只能链接LAPACK和BLAS。我也因为没有阅读自述文件而感到内疚,所以不要感觉不好。我正在交叉编译并获取对我的LAPACK和BLAS的未定义引用:''cgemv_','sdot_',...等等... – Matt

0

作为5.0.0(也可能适用于早期版本)

你确实需要-larmadillo,在的Fedora 21-llapack-lopenblas不是excplicitly必要了。

0

通过比较以前编译的代码与这个线程的问题,发现了一个奇怪的现象,强调gnu cc的参与(我不是这方面的专家):在我的机器编译成功取决于参数的顺序到gcc/g ++,其中 g ++ infile -o outfile -libarmadillo ...有效,但是 g ++ -libarmadillo infile -o outfile ...没有(几乎)与上面提到的相同的错误。 (希望有帮助)。

相关问题