7

当我尝试编译 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
  • lapack-3.4.0
  • 升压1.48.0
  • 最新版本的 ATLAS

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

4

3 回答 3

16

Thank you so much to osgx! After reading his comment, I took a second look at the README file! It turns out I was missing '-O1 -larmadillo' in the command!

Here's the command I used to get it working:

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

Stupid mistake, I know.... It just goes to remind you how important it is to read the README.

The README also mentions:

If you get linking errors, or if Armadillo was installed manually and you specified that LAPACK and BLAS are available, you will need to explicitly link with LAPACK and BLAS (or their equivalents), for example:

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

I didn't have to include '-llapack -lblas' but maybe this will help anyone else who's having similar problems.

于 2012-01-25T19:13:38.900 回答
1

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

于 2017-04-23T20:40:20.040 回答
0

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

您实际上需要-larmadillo, onFedora 21 -llapack并且-lopenblas不再明确需要。

于 2016-02-01T17:36:18.843 回答