2

I want to use Armadillo with Eclipse. However all the instructions to link Armadillo is given for Visual Studio. Now I followed the instructions outlined in the ReadMe file of the Armadillo library. I added the Armadillo include folder in project(right click)->properties->C/C++ Build->Settings->Cross G++ Compiler->Includes->Inlcude paths(-I) and then I added the libraries folder (The library folder contain lapack and blas .lib and .dll files) in project(right click)->properties->C/C++ Build->Settings->Cross G++ Linker->Libraries->Library search path (-L).

However when I compile the code in the Eclipse I get the error

.....armadillo_bits/lapack_wrapper.hpp:37: undefined reference to `dgetrf_'.

Shouldn't it simply search for .lib files in the library folder and include them during compiling? I would appreciate any help regarding this matter.

Regards, TM

francis
  • 9,525
  • 2
  • 25
  • 41
hellfragger
  • 143
  • 1
  • 4
  • 12

3 Answers3

2

Linking the Armadillo library to an Eclipse project can be done and you were about to do it ! It's pretty much the same as for any other library.

In the properties of the project :

  • GCC C++ Compiler -> Includes : add the path to the file armadillo (where namespace arma is declared) to the include search path (option -I). Example : /home/alpha/soft/armadillo-4.400.1/include

  • GCC C++ Linker -> Libraries : add the path to the file libarmadillo.so... in the library search path (option -L) Example : /home/alpha/soft/armadillo-4.400.1 . Add armadillo, lapack, blas and m as libraries (option -l). m is for math.

Here are the calls to the compiler and the linker as produced by eclipse :

make all 
Building file: ../src/armaeclip.cpp
Invoking: GCC C++ Compiler
g++ -I/home/alpha/soft/armadillo-4.100.1/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/armaeclip.d" -MT"src/armaeclip.d" -o "src/armaeclip.o" "../src/armaeclip.cpp"
Finished building: ../src/armaeclip.cpp



Building target: armaeclip
Invoking: GCC C++ Linker
g++ -L/home/alpha/soft/armadillo-4.100.1 -o "armaeclip" ./src/armaeclip.o   -larmadillo -lblas -lm -llapack
Finished building target: armaeclip
**** Build Finished ****

As you run the code, you might get something like :

error: det(): use of ATLAS or LAPACK needs to be enabled terminate called after throwing an instance of 'std::logic_error' what(): det(): use of ATLAS or LAPACK needs to be enabled Abandon (core dumped)

To avoid this problem, follow the advise of the faq of Armadillo : uncomment #define ARMA_USE_LAPACK in file /home/alpha/soft/armadillo-4.100.1/include/config.hpp and rebuild your project.

Community
  • 1
  • 1
francis
  • 9,525
  • 2
  • 25
  • 41
  • Hi Francis, Thank you for the advise. However I don't have .so files of lapack, blas, m or armadillo. The only library files I have are of the form lapack_WIN64_MT.lib and blas_WIN64_MT.lib. When I link the Armadillo folder and add lapack and blas as libraries I get the error "cannot find lapack and blas" So I am assuming I am missing .so files but where can I find them? – hellfragger May 29 '15 at 13:38
  • Could you try to add `lapack_WIN64_MT` and `blas_WIN64_MT` as libraries instead of `lapack` and `blas` ? According to the [naming convention of MinGW](http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use), it might solve your problem. – francis May 29 '15 at 18:12
  • I tried but it reads cannot find lapack_WIN64_MT and cannot find blas_WIN64_MT. I kind of gave up and using Eigen Liner Algebra Library – hellfragger Jun 04 '15 at 19:08
  • 1
    @francis It still works perfectly! Thank you! You should add "Add only the text "armadillo", "lapack", "blas" and "m" at libraries (option -l)". Got very confused. – euraad Dec 16 '18 at 20:34
0

You can also create GNU Autotools projects and add following line:

bin_PROGRAMS=armadillo_example
armadillo_example_SOURCES=armadillo_example.cpp
armadillo_example_LDADD=-larmadillo

To Makefile.am file where your source code exist.

0

If you don't require optimized BLAS libraries, you can use the BLAS and LAPACK libraries that come with Armadillo.

  1. Project properties > C/C++ Build > Settings > GCC C++ Compiler > Includes > Include paths (-l): C:\armadillo-x.xxx.x\include
  2. Then in Environment Variables > System variables, modify the Path variable and add: C:\armadillo-x.xxx.x\examples\lib_win64\
  3. Project properties > C/C++ General > Paths and Symbols > Libraries: blas_win64_MT and lapack_win64_MT (it is important to add them this way, with no path or .lib/.dll)

  4. Then in Environment Variables > System variables, modify the Path variable and add: C:\armadillo-x.xxx.x\examples\lib_win64\

And your Armadillo library in Eclipse is good to go.

I've used Eclipse 4.14.0 and Armadillo 9.850.1.

JGarreta
  • 1
  • 1