我正在尝试构建 Bytecoin Windows 上的源代码,我遇到了 CMake 和 Boost 库的问题。首先,我尝试获取 Boost 1.55 并自己编译。由于某种原因,靠近末尾的一两个库没有编译,但我认为 CMake 至少会识别已编译的库。相反,我在尝试加载 CMake 项目时遇到此错误:
Error:Unable to find the requested Boost libraries. Boost version: 1.55.0 Boost include path: C:/Program Files/boost/boost_1_55_0 Could not find the following Boost libraries: boost_system boost_filesystem boost_thread boost_date_time boost_chrono boost_regex
boost_serialization boost_program_options No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.
然后我尝试向 find_package() 添加一个 HINT。它试图解析一条奇怪的路径,但不确定它在哪里这样做:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindBoost.cmake:273 (if): Syntax error in cmake code at
C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindBoost.cmake:273
when parsing string
${Boost_C:/PROGRAM FILES/BOOST/BOOST_1_55_0_LIBRARY_RELEASE}
阅读一些关于我添加环境变量的 SO 答案:
C:\Users\Misha>set
BOOST_INCLUDEDIR=C:\local\boost_1_55_0 BOOST_LIBRARYDIR=C:\local\boost_1_55_0\lib32-msvc-12.0 BOOST_ROOT=C:\local\boost_1_55_0\boost
此时我尝试使用 precompiled libs ,什么都没有。
CMkeLists.txt
find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
#find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options HINT "C:/Program Files/boost/boost_1_55_0")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if (MINGW)
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
elseif (APPLE)
set(Boost_LIBRARIES "${Boost_LIBRARIES}")
elseif (NOT MSVC)
set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
endif ()
我不熟悉 CMake,所以这可能是一个简单的修复。我只是看不到它。
最佳答案
我遇到了同样的错误,但已解决。我的 BOOST 库是在 Windows 7(64 位)上使用 Gcc 6.3 构建的。
我在 CMakeLists.txt
中设置了 Boost_DEBUG on
并找到了
-- [ C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1620 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-mgw63-mt-1_67;libboost_system-mgw63-mt;libboost_system-mt-1_67;libboost_system-mt;libboost_system
这意味着 FindPackage(Boost)
正在搜索 libboost_system-mgw63-mt-1_67
但我的库名称是 libboost_system-mgw63-mt-x64-1_67
。
所以我从所有库名称中删除了 X64
,现在它可以正常工作了。
关于c++ - 无法找到请求的 Boost 库 Windows Cmake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34815536/