我试图在Windows 8 我配置的CMakeLists.txt文件,安装MLPack:链接到犰狳库与CMake的
set(ARMADILLO_LIBRARY "C:\\Program Files (x86)\\armadillo\\lib")
set(ARMADILLO_INCLUDE_DIR "C:\\Program Files (x86)\\armadillo\\include")
然后,当我跑的CMake我有一整系列这样的警告的:
WARNING: Target "mlpack" requests linking to directory "C:\Program Files (x86)\armadillo\lib". Targets may link only to libraries. CMake is dropping the item.
在\ mlpack-1.0.4的\ src \ mlpack目录中我发现了另一个CMakeLists与文件:
target_link_libraries(mlpack
${ARMADILLO_LIBRARIES}
${Boost_LIBRARIES}
${LIBXML2_LIBRARIES}
)
我改变(不知道这是一个好主意):跑步让我有一大堆这样的错误的时候
-- Found Armadillo: C:\Program Files (x86)\armadillo\lib (found suitable version "3.800.2", minimum required is "2.4.2")
-- Found LibXml2: C:\cpp\libraries\libxml2-2.7.8.win32\lib (found suitable version "2.7.8", minimum required is "2.6.0")
-- Boost version: 1.53.0
-- Found the following Boost libraries:
-- program_options
-- unit_test_framework
-- Boost version: 1.53.0
-- Found the following Boost libraries:
-- random
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Configuring done
-- Generating done
-- Build files have been written to: C:/cpp/libraries/mlpack-1.0.4
但现在:
target_link_libraries(mlpack
${Boost_LIBRARIES}
)
link_directories(mlpack
${ARMADILLO_LIBRARIES}
${LIBXML2_LIBRARIES}
)
然后CMake的似乎可以流畅运行:
Linking CXX executable ..\..\..\..\gmm.exe
CMakeFiles\gmm.dir/objects.a(gmm_main.cpp.obj):gmm_main.cpp:(.text+0xb9): undefined reference to `wrapper_dgemv_'
CMakeFiles\gmm.dir/objects.a(gmm_main.cpp.obj):gmm_main.cpp:(.text$_ZN4arma6auxlib10det_lapackIdEET_RKNS_3MatIS2_EEb[__ZN4arma6auxlib10det_lapackIdEET_RKNS_3MatIS2_EEb]+0x115): undefined reference to `wrapper_dgetrf_'
经过调查后似乎与犰狳有关。
任何想法发生了什么?我想我应该使用armadillo的target_link_libraries,但我不知道如何。
是的,您绝对需要在您自己的CMakeLists.txt中将target_link_libraries()链接到Armadillo。你可以张贴你的完整/相关部分CMakeLists.txt – 2013-04-11 03:43:49
Thx很多。我想知道我是否可以真正发布整个文件,这是相当长的。对于相关的部分,我刚刚找到一行“find_package(Armadillo 2.4.2 REQUIRED)”,后面跟着一行“include_directories($ {ARMADILLO_INCLUDE_DIRS})”。但我是真正的初学者,我可能会错过某些东西。完整的文件在这里:http://www.mlpack.org/files/mlpack-1.0.4.tar.gz我只是在文章中描述的变化... – Vince 2013-04-11 04:01:13
添加如下内容:target_link_libraries(gmm.exe $ {} ARMADILLO_LIBRARIES)。看看这是否有效。或者只是使用“gmm”代替“gmm.exe”,然后再次尝试 – 2013-04-11 06:53:33