I'm trying to cross-compile (from ix86
to ARM
) a code on the Eclipse IDE using the armadillo library.
I'm using the arm-linux-gnueabihf
compiler from linaro.org.
I already set up everything on Eclipse and can sucessfully cross compile c++ code.
After following this tutorial I could generate the liblapack.a
, libf2c.a
and liblas.a
cross compiled libraries.
I think I correctly linked on Eclipse:
Cross G++ Linker -> Libraries ->
Libraries (-l)
lapack
f2c
blas
Library Search Path (-L)
Added the path to liblapack.a, libf2c.a and liblas.a files.
I can run simples code like the following without any problem. I think it's because simple programs like this don't need the cross compiled libraries, just the armadillo.
#include <armadillo>
#include <iostream>
using namespace std;
using namespace arma;
int main() {
mat A = randu(4,4);
cout << "A:\n" << A << "\n";
return 0;
}
But, when I try to compile my code with matrices multiplications or any other function that uses functionalities from the cross-compiled libraries, like this one:
#define ARMA_DONT_USE_WRAPPER
#define ARMA_USE_LAPACK
#define ARMA_USE_BLAS
#include <armadillo>
#include <iostream>
using namespace std;
using namespace arma;
int main() {
mat A = randu(4,4);
mat B = randu(4,4);
cout << "A:\n" << A << "\n";
//Matrices multiplication
cout << A*B << endl;
return 0;
}
I get the following errors:
'Building target: test'
'Invoking: Cross G++ Linker'
arm-linux-gnueabihf-g++ -L"[path to the liblapack.a,liblas.a and libf2c.a files]" -o "test" ./src/test.o -llapack -lf2c -lblas
./src/test.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*)':
[path to the armadillo library]\include/armadillo_bits/translate_blas.hpp:36: undefined reference to `dgemv_'
./src/teste.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*)':
[path to the armadillo library]\include/armadillo_bits/translate_blas.hpp:62: undefined reference to `dgemm_'
collect2.exe: error: ld returned 1 exit status
makefile:45: recipe for target 'test' failed`
make: *** [test] Error 1
"make all" terminated with exit code 2. Build might be incomplete
Very similar problem as in here : Armadillo + BLAS + LAPACK , but on my case the compilation just crashes everytime.
I already cross-compiled another time the libraries to see if was this the problem and had no success.