6

I have a question regarding the use of Armadillo.

I'm using Ubuntu 12.10, and the gcc compiler in Code::Blocks. I installed LAPACK and BLAS using the synaptic package manager. I also installed Armadillo once using the synaptic package manager, once by hand with CMake. CMake found the LAPACK and BLAS libraries while making the configurations for the armadillo compilation. Furthermore, I linked the libraries of BLAS and LAPACK in Code::Blocks in 'Build Options"->"Linker'`.

However, whenever I want to build my project, I get the error message:

 In function `void arma::lapack::getrf<double>(int*, int*, double*, int*, int*, int*)':|
/usr/include/armadillo_bits/lapack_wrapper.hpp|41|undefined reference to `wrapper_dgetrf_'|

It obviously means that armadillo cannot find LAPACK, but what did I do wrong?

I also discommented the respective lines in the armadillo_bits/config.hpp file, so that it looks like this:

    #if !defined(ARMA_USE_LAPACK)
    //#define ARMA_USE_LAPACK
    //// Uncomment the above line if you have LAPACK or a high-speed replacement for LAPACK,
    //// such as Intel MKL, AMD ACML, or the Accelerate framework.
    //// LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse.
    #endif

    #if !defined(ARMA_USE_BLAS)
    //#define ARMA_USE_BLAS
    //// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS,
    //// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate framework.
    //// BLAS is used for matrix multiplication.
    //// Without BLAS, matrix multiplication will still work, but might be slower.
    #endif

    /* #undef ARMA_USE_WRAPPER */
    //// Comment out the above line if you're getting linking errors when compiling your programs,
    //// or if you prefer to directly link with LAPACK and/or BLAS.
    //// You will then need to link your programs directly with -llapack -lblas instead of -larmadillo

The error appears first when I try to set up a matrix with integers, so

  Mat<int> element_nodes;

I would appreciate helpful answers. I did search the internet for a couple of hours. Also, if you need more source code, let me know.

user2477647
  • 61
  • 1
  • 1
  • 3

3 Answers3

1

Looks like you have two copies of Armadillo installed, which have different configurations. If in doubt, link your programs with:

g++ prog.cpp -o prog -O2 -larmadillo -llapack -lblas

You may also want to have a look at Armadillo's FAQ and a previous Stackoverflow question.

Community
  • 1
  • 1
mtall
  • 3,574
  • 15
  • 23
  • I'm almost sure I don't have two copies of Armadillo. I first deleted all the files that have armadillo in their name, then I updated to the latest version (3.9.x). Still, Cmake finds LAPACK and BLAS, but Armadillo doesn't. – user2477647 Jun 18 '13 at 22:09
  • Thanks, your suggestion with linking the libraries worked. For more comfort, I will try to do the linking inside Code::Blocks. Do you know how that works? – user2477647 Jun 19 '13 at 06:26
0

I guess you have not uncommented the define line yet!:

if !defined(ARMA_USE_LAPACK)

//#define ARMA_USE_LAPACK
^^
||

Here

Community
  • 1
  • 1
0

If you have used the blas and lapack library files from the downloaded armadillo package, maybe they do not work because in the ReadMe file , it said that they are from a third party and so I downloaded from other sources and then it compiled fine