我已经使用Visual Studio 2017从源代码编译了Boost,我正在使用CMake 3.9.3在我的CMakeLists.txt中使用以下命令找到它:
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库也是如此。
我该如何解决这个问题?
答案 0 :(得分:1)
我需要将-DBoost_COMPILER="-vc141"
传递给CMake以使其正常工作(-vc141
与Boost库文件名中的字符串相同)。