我现在已经在这里待了几个小时,感觉很愚蠢。有问题的库是spdlog,它只是一大堆标题。我正在使用 CMake 和 cygwin 进行编译。
的CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
project(spdlog_test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(E:/Dev/libraries/spdlog)
link_directories(E:/Dev/libraries/spdlog)
set(SOURCE_FILES main.cpp)
add_executable(spdlog_test ${SOURCE_FILES})
target_link_libraries(spdlog_test spdlog)
所有路径都是正确的。
构建时输出:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lspdlog
collect2: error: ld returned 1 exit status
CMakeFiles/spdlog_test.dir/build.make:94: recipe for target 'spdlog_test.exe' failed
make[2]: *** [spdlog_test.exe] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/spdlog_test.dir/all' failed
make[1]: *** [CMakeFiles/spdlog_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2