Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
801 views
in Technique[技术] by (71.8m points)

linker - Armadillo + BLAS + LAPACK: Linking error?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...