【问题标题】:Armadillo + BLAS + LAPACK: Linking error?Armadillo + BLAS + LAPACK:链接错误?
【发布时间】:2017-04-24 04:40:20
【问题描述】:

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

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

【问题讨论】:

  • 看起来你的犰狳配置不正确,或者编译字符串中没有提到所需的库。你能展示一下如何编译example1.cpp

标签: linker lapack blas armadillo


【解决方案1】:

非常感谢osgx!在阅读了他的评论后,我再次查看了 README 文件!原来我在命令中缺少“-O1 -larmadillo”!

这是我用来让它工作的命令:

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

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

自述文件还提到:

如果您遇到链接错误,或者 Armadillo 是手动安装的 并且您指定了 LAPACK 和 BLAS 可用,您将 需要明确链接 LAPACK 和 BLAS(或它们的等价物), 例如:

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

我不必包含“-llapack -lblas”,但也许这会对遇到类似问题的其他人有所帮助。

【讨论】:

  • 这正是我想要的!只需要链接 LAPACK 和 BLAS。我也因为没有阅读自述文件而感到内疚,所以不要难过。我正在交叉编译并获得对我的 LAPACK 和 BLAS 的未定义引用:'cgemv_', 'sdot_',...等...
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

    您实际上需要 -larmadillo,在 Fedora 21-llapack-lopenblas 不再明确需要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      • 2012-02-18
      • 1970-01-01
      相关资源
      最近更新 更多