*我知道对此有很多问题,但在谈论 CMake 时它们根本没有多大帮助,因此我决定提出这个问题 *
因此,我正在研究 CLion,它使用 CMake 导入并为编译器提供参数,并成功包含(导入)了位于名为“ExternalLibraries”的文件夹中的外部库(谷物:将类序列化为 json 文件)我的项目文件夹的根目录。它工作得很好,直到我重新启动 IDE 并尝试再次运行代码......它返回了一个编译错误(我认为)。
我的 CMake 文件如下所示:
cmake_minimum_required(VERSION 3.3)
project(xMemory)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories ("${PROJECT_SOURCE_DIR}/ExternalLibraries/cereal-1.1.2/include/")
set(SOURCE_FILES main.cpp xObject.cpp xObject.h)
add_executable(xMemory ${SOURCE_FILES})
target_link_libraries (xMemory cereal)
当我尝试运行/编译时,shell 给了我这个:
/home/lunaticsoul/Documents/clion-1.2.4/bin/cmake/bin/cmake --build /home/lunaticsoul/.CLion12/system/cmake/generated/95701c38/95701c38/Debug0 --target xMemory -- -j 4
Scanning dependencies of target xMemory
[ 33%] Building CXX object CMakeFiles/xMemory.dir/xObject.cpp.o
[ 66%] Building CXX object CMakeFiles/xMemory.dir/main.cpp.o
[100%] Linking CXX executable xMemory
/usr/bin/ld: cannot find -lcereal
collect2: error: ld returned 1 exit status
make[3]: *** [xMemory] Error 1
make[2]: *** [CMakeFiles/xMemory.dir/all] Error 2
make[1]: *** [CMakeFiles/xMemory.dir/rule] Error 2
make: *** [xMemory] Error 2
我不确定发生了什么,因为库似乎实际上已导入代码(包括谷物时没有红色字母),正如我之前所说,我认为它刚刚停止工作。
有人可以告诉我我的 CMake 文件是否有问题吗?
PD:这是一张截图,以防万一有人需要。
PD2:我正在使用基本操作系统:Freya(Ubuntu 14.04)