我想在我的项目中使用UnitTest++,但是编译时出错了:
CMakeFiles/BNN.dir/main.cpp.o:-1: In function `main':
BNN/main.cpp:-1: error: undefined reference to `UnitTest::RunAllTests()'
:-1: error: collect2: error: ld returned 1 exit status我在网上搜索答案,并尝试了几件事情,这就是我现在所拥有的:
project(BNN)
cmake_minimum_required(VERSION 2.8)
file(GLOB SRC "*.cpp" "src/*.h" "src/*.cpp")
file(GLOB DATA_FILE "*.md")
find_package(UnitTest++ REQUIRED)
include_directories(${UnitTest++_INCLUDE_DIRS})
set(LIBS ${LIBS} ${UnitTest++_LIBRARY})
add_executable(${PROJECT_NAME} ${SRC} ${DATA_FILE})
target_link_libraries(${PROJECT_NAME} ${LIBS})我按照官方指南建造图书馆:
cd path/to/unittest-cpp/builds
cmake -G "<Choose a valid generator>" ../
cmake --build ./
sudo cmake --build ./ --target install我的操作系统是ArchLinux。
我要做什么才能用cmake编译它呢?
发布于 2016-06-08 19:38:13
我通过将cmake文件更改为:
project(BNN)
cmake_minimum_required(VERSION 2.8)
include_directories(src)
file(GLOB SOURCES "*.cpp" "src/*.h" "src/*.cpp" "tests/*.cpp")
file(GLOB DATA_FILE "*.md")
add_executable(${PROJECT_NAME} ${SOURCES} ${DATA_FILE})
target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/../unittest-cpp/builds/libUnitTest++.a)https://stackoverflow.com/questions/37710344
复制相似问题