/ usr / lib / ld无法打开输出文件unit_test:是一个目录

时间:2016-08-31 15:12:54

标签: c++ linux cmake clion

我在用C ++编写类似小行星的视频游戏时遇到问题,我将在几天内进行考试。我正在使用JetBrains CLion 1.3 IDE。当我尝试使用GoogleTest框架(版本1.7.0)实现单元测试时,编译器会收到此错误:

[ 40%] Built target core
[ 80%] Built target asteroids
[ 85%] Built target gtest
[ 87%] Linking CXX executable unit_test
/usr/bin/ld: impossibile aprire il file di output unit_test: È una directory
collect2: error: ld returned 1 exit status
CMakeFiles/unit_test.dir/build.make:95: set di istruzioni per l'obiettivo "unit_test" non riuscito
make[2]: *** [unit_test] Errore 1
CMakeFiles/Makefile2:104: set di istruzioni per l'obiettivo "CMakeFiles/unit_test.dir/all" non riuscito
make[1]: *** [CMakeFiles/unit_test.dir/all] Errore 2
make[1]: *** Attesa per i processi non terminati....
[ 91%] Built target gtest_main
Makefile:127: set di istruzioni per l'obiettivo "all" non riuscito
make: *** [all] Errore 2

我想问的是这条线:

/usr/bin/ld: impossibile aprire il file di output unit_test: È una directory

翻译自意大利语,意思是(字面意思):

/usr/bin/ld: cannot open output file unit_test: Is a directory

我的代码出了什么问题?我想这是一个CMakeLists.txt问题,所以这里是我的CMakeLists.txt文件(一个来自主目录,另一个来自"测试子目录"):

主要目录CMakeLists.txt (有关googletest版本的部分内容):

add_subdirectory(test)

add_executable(unit_test main.cpp)
add_library(core ${SOURCE_FILES})
target_link_libraries(unit_test core)

测试目录CMakeLists.txt (完整):

add_subdirectory(googletest)
set(gtest_SOURCE_DIR, googletest)
include_directories(${gtest_SOURCE_DIR}/include
        ${gtest_SOURCE_DIR})

set(SOURCE_FILE runAllTests runAllTests.cpp AsteroidFixture.cpp)
add_executable(runAllTests ${SOURCE_FILE})
target_link_libraries(runAllTests gtest gtest_main core)

我创建了AsteroidFixture.cpp文件,作为主要gtest函数的第一次尝试,但它本质上是一个空文件。

0 个答案:

没有答案