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