qtcreator
同时支持qmake
和cmake
进行跨平台开发和
qmake
适用于 msvc
和 MinGW
在 Windows
上构建。但是,我更愿意只支持一种工具:cmake
。
CMakeLists.txt
位于 via-httplib在 linux
上以及在 Windows
上使用 cmake
构建 msvc
时工作正常。
但是,在 Windows
上使用 cmake
构建 MinGW
时,出现以下错误:
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.Boost version: 1.69.0
Boost include path: D:/DevLibraries/boost/boost_1_69_0
Could not find the following Boost libraries:
boost_system
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.
BOOST_LIBRARYDIR
和 BOOST_ROOT
环境变量均已设置并在使用 Visual Studio 15 2017 Win64
生成器和默认 native 编译器时找到
错误消息表明,当使用 MinGW Makefiles
和默认 native 编译器时,cmake
找到了 BOOST_ROOT
环境变量,但没有找到 BOOST_LIBRARYDIR
。所以它似乎与此处描述的问题不同:Cmake doesn't find Boost
这是 FindBoost.cmake
中的错误吗?有“变通办法”吗?
最佳答案
这是 FindBoost.cmake
中的 _boost_ARCHITECTURE_TAG
的问题,如第 1518 行所述。
添加该标签是为了处理 Boost 1.66.0 及更高版本。
它没有将 MinGW
的 _boost_ARCHITECTURE_TAG
设置为 -x64
,因此它正在搜索 boost 库名称,例如:
libboost_system-mgw73-mt-d-1_69.a
代替:
libboost_system-mgw73-mt-d-x64-1_69.a
有一个解决方法:将 cmake
变量:Boost_ARCHITECTURE
设置为 -x64
。
注意:将 Boost_ARCHITECTURE
设置为环境变量不起作用,因为 FindBoost.cmake
不会将 Boost_ARCHITECTURE
读取为环境变量。
关于c++ - 在 Windows 上使用 MinGW 构建时,cmake FindBoost 找不到 Boost 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53943885/