Armadillo + BLAS + LAPACK: Linking error?

后端 未结 3 1350
醉话见心
醉话见心 2020-12-17 00:45

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::bl         


        
相关标签:
3条回答
  • 2020-12-17 01:22

    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.

    0 讨论(0)
  • 2020-12-17 01:48

    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).

    0 讨论(0)
  • 2020-12-17 01:49

    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.

    0 讨论(0)
提交回复
热议问题