'Undefined Reference to LAPACK wrapper of Armadillo
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.
Solution 1:[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.
Solution 2:[2]
I guess you have not uncommented the define line yet!:
if !defined(ARMA_USE_LAPACK)
//#define ARMA_USE_LAPACK
^^
||
Here
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | Community |
| Solution 3 | Donepudi Bhargava |
