我已经用Visual Studio2017从源代码编译了Boost,并在我的CMakeLists.txt中使用CMake 3.9.3通过以下命令找到它:
find_package(Boost REQUIRED COMPONENTS filesystem)我像这样调用CMake:
cmake -G "Visual Studio 15 2017" ..
-DBOOST_ROOT="C:\Users\emlai\src\libs\boost_1_65_0"
-DBOOST_LIBRARYDIR="C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0"我得到以下消息:
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1902 (message):
Unable to find the requested Boost libraries.
Boost version: 1.65.0
Boost include path: C:/Users/emlai/src/libs/boost_1_65_0
Could not find the following Boost libraries:
boost_filesystem
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:31 (find_package)
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
build/cmake-modules/FindSDL2.cmake:173 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:42 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeError.log".dir C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0的输出显示文件系统库已经就位。
我已经尝试了here的所有答案,但没有成功。从here下载的预构建Boost库也会发生同样的情况。
我该如何解决这个问题?
发布于 2017-09-30 04:54:48
我需要将-DBoost_COMPILER="-vc141"传递给CMake以使其工作(-vc141与Boost库文件名中的字符串相同)。
https://stackoverflow.com/questions/46496549
复制相似问题