Linking MLPACK, Armadillo and LAPACK/BLAS in Qt Creator Project in Windows 7

2.1k Views Asked by At

I am trying to integrate MLPACK with my project in Qt Creator (using MinGW as a compiler) and I keep getting linking errors related to LAPACK and Armadillo. I compiled LAPACK and BLAS myself and run a test script and everything seems to be good there. Also, I compiled Armadillo (without the wrapper) using CMake-gui with LAPACK and BLAS enabled and example1.cpp compiles and runs with no problem. MLPACK compiles and finds all the needed dependencies.

My .pro file has the following:

## Armadillo
INCLUDEPATH += $$PWD/MLPACK/dependencies/armadillo/include

## LAPACK
unix|win32: LIBS += -L$$PWD/MLPACK/dependencies/lapack/ -llapack

## BLAS
unix|win32: LIBS += -L$$PWD/MLPACK/dependencies/blas/ -lblas

## LibXML2
unix|win32: LIBS += -L$$PWD/MLPACK/dependencies/libxml2/lib/ -lxml2
INCLUDEPATH += $$PWD/MLPACK/dependencies/libxml2/include
DEPENDPATH += $$PWD/MLPACK/dependencies/libxml2/include
unix|win32-g++: PRE_TARGETDEPS += $$PWD/MLPACK/dependencies/libxml2/lib/libxml2.a

## Boost
unix|win32: LIBS += -L$$PWD/../../boost_1_54_0/stage/lib/ -lboost_program_options-mgw48-mt-1_54
INCLUDEPATH += $$PWD/../../boost_1_54_0
DEPENDPATH += $$PWD/../../boost_1_54_0
unix|win32-g++: PRE_TARGETDEPS += $$PWD/../../boost_1_54_0/stage/lib/libboost_program_options-mgw48-mt-1_54.a

unix|win32: LIBS += -L$$PWD/../../boost_1_54_0/stage/lib/ -lboost_random-mgw48-mt-1_54
unix|win32-g++: PRE_TARGETDEPS += $$PWD/../../boost_1_54_0/stage/lib/libboost_random-mgw48-mt-1_54.a

unix|win32: LIBS += -L$$PWD/../../boost_1_54_0/stage/lib/ -lboost_unit_test_framework-mgw48-mt-1_54
unix|win32-g++: PRE_TARGETDEPS += $$PWD/../../boost_1_54_0/stage/lib/libboost_unit_test_framework-mgw48-mt-1_54.a

## MLPACK
unix|win32: LIBS += -L$$PWD/MLPACK/lib/ -lmlpack
INCLUDEPATH += $$PWD/MLPACK/include
DEPENDPATH += $$PWD/MLPACK/include
unix|win32-g++: PRE_TARGETDEPS += $$PWD/MLPACK/lib/libmlpack.a

When I compile my project I am getting this:

C:/Workspace/OffLineSorter/MLPACK/lib//libmlpack.a(pca.cpp.obj):pca.cpp:(.text$_ZN4arma6auxlib11svd_dc_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EE[__ZN4arma6auxlib11svd_dc_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EE]+0x24f): undefined reference to `dgesdd_'
Makefile.Debug:252: recipe for target 'debug\OffLineSorter.exe' failed
C:/Workspace/OffLineSorter/MLPACK/lib//libmlpack.a(pca.cpp.obj):pca.cpp:(.text$_ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc[__ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc]+0x286): undefined reference to `dgesvd_'
C:/Qt/Qt5.3.0/Tools/mingw482_32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: C:/Workspace/OffLineSorter/MLPACK/lib//libmlpack.a(pca.cpp.obj): bad reloc address 0x286 in section `.text$_ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc[__ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc]'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [debug\OffLineSorter.exe] Error 1
mingw32-make[1]: Leaving directory 'C:/Workspace/build-OffLineSorter-Desktop_Qt_5_3_0_MinGW_32bit-Debug'
mingw32-make: *** [debug] Error 2
Makefile:34: recipe for target 'debug' failed

Any ideas of what I might be doing wrong? Thanks for your help!

1

There are 1 best solutions below

1
On

Can you try with the recently released mlpack 1.0.10? I rewrote the CMake FindArmadillo script so that it properly detects when ARMA_USE_WRAPPER is not being used (which is true in your case) and links directly to LAPACK or BLAS.

It is not tested in your particular setup (MinGW + Win7) because I have not yet had a chance to set up that compilation environment, but I think it should work better.

You may want to consult the mlpack mailing list archives too; there has been some discussion there in the past about the use of MinGW: https://mailman.cc.gatech.edu/pipermail/mlpack/

Thanks,

Ryan