Adding Armadillo to Qt project

3.5k views Asked by At

I am trying to run a test for the Armadillo library (5.2) which I have downloaded and I have uncommented the lines ARMA_USE_LAPACK and ARMA_USE_BLAS in the config.hpp file as recommended for Windows here . I have set the .pro file as such

QT       += core

QT       -= gui

TARGET = armatest
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

SOURCES += \
    main.cpp

INCLUDEPATH += C:\Armadillo\include

LIBS += -LC:\Armadillo\lib_win64
    -llapack_win64_MT
    -lblas_win64_MT

Considering that lapack_win64_MT.lib and blas_win64_MT.lib are the libraries located in C:\Armadillo\lib_win64\

The error I keep on receiving is

undefined reference to 'dgetrf_'
undefined reference to 'ddot_'
undefined reference to 'dgemv_'

etc. as if I am not linking the libraries properly. What am I missing?

I am using MinGW 4.9.1 as a compiler

2

There are 2 answers

0
RDGuida On BEST ANSWER

The problem was due to two reasons

The libraries were x64 and my compiler was 32-bit (even though my machine is x64)

The LIBS path had to be written with backslashes

LIBS += \
    -LC:\Armadillo\lib32 \
    -lliblapack \
    -llibblas
4
Dirk is no longer here On

You are missing LAPACK and BLAS to supply the actual underlying linear algebra operations.

This is documented in the Armadillo FAQ among other places. You may need to reinstall or rebuild Armadillo for your system; it does not ship with LAPACK and BLAS.

My preferred approach would be to build a standalone Armadillo test program (and maybe you already have), build one for Qt -- and then tried to join the build instructions.

Edit: You are falling for the common problem of mixing MinGW and VC++. The Armadillo site clearly says

As a courtesy, the Armadillo package contains pre-compiled 64 bit versions of LAPACK and BLAS, as well as MSVC project files to compile the example programs. The MSVC project files were tested on 64 bit Windows 7 with Visual C++ 2012. You may need to make adaptations for later versions of Windows and/or the compiler.

which does not help you with MinGW. You need to find yourself MinGW's compiled LAPACK and BLAS.