犰狳+ BLAS + LAPACK:链接错误?
当我尝试编译 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
When I try to compile example1.cpp that comes with Armadillo 2.4.2, I keep getting the following linking error:
/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
Can someone help? I manually installed
- latest version of BLAS
- lapack-3.4.0
- boost-1.48.0
- latest version of ATLAS
I'm using Ubuntu 11.04 on the MacBook Pro 7,1 model
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
非常感谢osgx!读完他的评论后,我又看了一眼 README 文件!原来我在命令中缺少“-O1 -larmadillo”!
这是我用来让它工作的命令:
愚蠢的错误,我知道......它只是提醒您阅读自述文件是多么重要。
自述文件还提到:
如果出现链接错误,或者是否手动安装了犰狳
并且您指定了 LAPACK 和 BLAS 可用,您将
需要显式链接 LAPACK 和 BLAS (或它们的等效项),
例如:
我不必包含“-llapack -lblas”,但这也许会对遇到类似问题的其他人有所帮助。
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:
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:
I didn't have to include '-llapack -lblas' but maybe this will help anyone else who's having similar problems.
从 5.0.0 开始(可能也适用于早期版本)
您实际上需要
-larmadillo
,在 Fedora 21 上-llapack
和-lopenblas
不再是明确必需的。As of 5.0.0 (might also apply to earlier versions)
You actually need
-larmadillo
, on Fedora 21-llapack
and-lopenblas
are not excplicitly necessary anymore.我刚刚通过比较以前工作的代码编译与该线程的问题,发现了一个奇怪的地方,强调 gnu cc 的参与(我不是这方面的专家):在我的机器上编译成功取决于参数的顺序gcc/g++ 其中
g++ infile -o outfile -libarmadillo ... 有效,但是
g++ -libarmadillo infile -o outfile ... 没有(几乎)出现与上面提到的相同的错误。
(希望有帮助)。
There's an oddity I just discovered by comparing previously working compilations of code with the very problem of this thread, stressing the involvement of the gnu cc (I'm no expert in this): on my machine compilation success depends on the order of parameters to the gcc/g++ where
g++ infile -o outfile -libarmadillo ... worked, but
g++ -libarmadillo infile -o outfile ... didnt with (almost) the same error as mentioned above.
(hope that helps).