Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Armadillo work on Windows?

I cannot make Armadillo 4.3 work on Windows. The library armadillo/include is included and I run g++ "-LC:\\Armadillo\\BLAS_Lapack" -o1 -o test.exe test.o -llapack -lblas, then I get the following error message:

C:/Armadillo/include/armadillo_bits/blas_wrapper.hpp:183: undefined reference to `wrapper_ddot_'
test.o: In function `ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_':
C:/Armadillo/include/armadillo_bits/blas_wrapper.hpp:34: undefined reference to `wrapper_dgemv_'
test.o: In function `ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_':
C:/Armadillo/include/armadillo_bits/blas_wrapper.hpp:69: undefined reference to `wrapper_dgemm_'

If I run g++ -o1 -o test.exe test.o -llapack -lblas, I get

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -llapack
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lblas

I did uncomment the configuration file config.hpp according to the README file.

Does anybody know how to make Armadillo work? (I am using Eclipse CDT.)

like image 354
MunHo Avatar asked Dec 11 '22 04:12

MunHo


2 Answers

It took a while to get this right, but it seems transparent once it works. I will explain step by step. (Make sure you have uncommented the correct lines as directed in the README of the config.hpp file)

The general command for compiling with blas/lapack (using the default provided with armadillo (current version 4.500.0) and does make it faster :)

g++ main.cpp -I C:{ARMADILLO_ROOT}\include -L C:{ARMADILLO_ROOT}\examples\lib_win64 -lblas_win64_MT -llapack_win64_MT

where each of the commands are as follows:

  1. g++: GNU G++ Compiler (using MinGW 4.9.1 C++ from equationsolution.com)

  2. main.cpp: My main file of the C++ program (I have an abstract and concrete class defining the Levenshtein algorithm)

  3. -I C:{ARMADILLO_ROOT}\include: The GCC C++ Compiler Include Path (To include the Armadillo library) where ARMADILLO_ROOT is where you have decompressed and placed your armadillo files

  4. -L C:{ARMADILLO_ROOT}\examples\lib_win64: The MinGW C++ Linker Library Link Path (To link the BLAS and LAPACK libraries) I have used the default libs provided with armadillo, I believe and according to the doc you may and should substitute these linear libraries in a production instance)

  5. -lblas_win64_MT -llapack_win64_MT: Identify the libraries to be used (name must match, so you cannot put -lblas or -llapack UNLESS your files are named that way - by default in this armadillo version they are named blas_win64_MT lapack_win64_MT (win64 since I am using both a MinGW/C++ 64bit and a 64bit armadillo [they should match])

Following this logic, you may configure eclipse (using eclipse Luna R1 4.4.1 -should be the same procedure on other versions) with the following:

  • Right Click the Project and Select "Properties" item in the popup menu
  • Under "C/C++ Build" on the left menu Select "Settings"
  • Under "GCC C++ Compiler" click on "Includes (-I)" and add the include path C:{ARMADILLO_ROOT}\include (Screenshot1)
  • Under "MinGW C++ Linker" click on "Libraries" add each "Libraries (-l)" as named blas_win64_MT lapack_win64_MT. (Screenshot2)
  • Under the same "MinGW C++ Linker" click on "Libraries" add a "Library search path (-L)" C:{ARMADILLO_ROOT}\examples\lib_win64
  • Click the "Apply" button before pressing "OK"

--Screenshot1 Screenshot1

--Screenshot2 Screenshot2

like image 72
snassr Avatar answered Dec 22 '22 22:12

snassr


It seems to work now! I am using the Lapack and BLAS from the webpage indicated in the Readme file that I compiled myself according to @enhzflep comments.

To link everything properly in Eclipse CDT right click on your project and go to properties, then:

  1. Under "C/C++ Build⟼Settings⟼GCC C++ Compiler⟼Command" type: g++ -I"C:\Armadillo\include" (replace with the correct path for your Armadillo folder). Make sure to do this for all Configurations (to be chosen in the drop-down menu at the top).
  2. Under "C/C++ Build⟼Settings⟼MinGW C++ Linker⟼Libraries" add lapack and blas to the Libraries.
  3. Under"C/C++ General⟼Paths and Symbols⟼GNU C++" add the path tot he include directory of your Armadillo folder C:\Armadillo\include.

It might be that it works with the original Lapack and BLAS files. It did not work for me, because I had only added the path to Armadillo under "C/C++ General⟼Paths and Symbols⟼GNU C++", which I guess only tells the editor what data types and functions to expect and not the compiler.

like image 34
MunHo Avatar answered Dec 22 '22 22:12

MunHo