我试图将MLPACK与我在Qt Creator中的项目集成(使用MinGW作为编译器),并且不断收到与LAPACK和Armadillo相关的链接错误。
我自己编译了LAPACK和BLAS,并运行了一个测试脚本,那里的一切似乎都很好。另外,我使用启用了LAPACK和BLAS的CMake-gui编译了Armadillo(没有包装器),并且example1.cpp编译并运行没有问题。
MLPACK编译并找到所有需要的依赖项。
我的.pro文件具有以下内容:
## 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
当我编译项目时,我得到的是:
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
对我可能做错的任何想法?
谢谢你的帮助!
最佳答案
您可以尝试使用最近发布的mlpack 1.0.10吗?我重写了CMake FindArmadillo脚本,以便它可以正确检测到何时未使用ARMA_USE_WRAPPER(在您的情况下是对的),并直接链接到LAPACK或BLAS。
未在您的特定设置(MinGW + Win7)中对其进行测试,因为我还没有机会设置该编译环境,但是我认为它应该可以更好地工作。
您可能还需要查阅mlpack邮件列表档案。过去曾有过有关使用MinGW的讨论:
https://mailman.cc.gatech.edu/pipermail/mlpack/
谢谢,
瑞安