在Windows上使用MinGW进行构建时,cmake FindBoost找不到Boost库
qtcreator
支持qmake
和cmake
进行跨平台开发和
qmake
对于在Windows
上构建的msvc
和MinGW
都可以正常工作.但是,我只想支持一种工具:cmake
.
qtcreator
supports both qmake
and cmake
for cross platform development and
qmake
works fine for both msvc
and MinGW
builds on Windows
. However, I'd prefer to support just one tool: cmake
.
位于 via-httplib 上的CMakeLists.txt
在linux
上以及使用时都可以正常工作cmake
在Windows
上构建msvc
.
但是,当使用cmake
在Windows
上构建MinGW
时,出现以下错误:
The CMakeLists.txt
at via-httplib works fine on linux
and when using cmake
to build msvc
on Windows
.
However, when using cmake
to build MinGW
on Windows
, I get the following error:
C:/Program上的Cake错误 文件/CMake/共享/cmake-3.13/Modules/FindBoost.cmake:2100(消息):
找不到请求的Boost库.
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
增强版本:1.69.0
Boost version: 1.69.0
增强包含路径:D:/DevLibraries/boost/boost_1_69_0
Boost include path: D:/DevLibraries/boost/boost_1_69_0
找不到以下Boost库:
Could not find the following Boost libraries:
boost_system
未找到Boost库.您可能需要设置BOOST_LIBRARYDIR 到包含Boost库的目录或BOOST_ROOT到 Boost的位置.
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.
在使用Visual Studio 15 2017 Win64
生成器和默认的本机编译器时,都设置并找到了BOOST_LIBRARYDIR
和BOOST_ROOT
环境变量
Both the BOOST_LIBRARYDIR
and BOOST_ROOT
environment variables are set and are found when using the Visual Studio 15 2017 Win64
generator and default native compilers
错误消息表明,使用MinGW Makefiles
和默认的本机编译器时,cmake
查找BOOST_ROOT
环境变量,但未找到BOOST_LIBRARYDIR
.因此,似乎与此处描述的问题不同: Cmake找不到Boost
The error message indicates that when using the MinGW Makefiles
and default native compilers, cmake
finds the BOOST_ROOT
environment variable but not BOOST_LIBRARYDIR
. So it does not seem to be the same problem described here: Cmake doesn't find Boost
这是FindBoost.cmake
中的错误吗?有解决方法"吗?
Is this a bug in FindBoost.cmake
? Is there a "work around"?
这是FindBoost.cmake
中的_boost_ARCHITECTURE_TAG
的问题,如第1518行所述.
已添加该标记以处理Boost 1.66.0和更高版本.
It is an issue with the _boost_ARCHITECTURE_TAG
in FindBoost.cmake
, described on line 1518.
The tag was added to handle Boost 1.66.0 and later versions.
它没有将MinGW
的_boost_ARCHITECTURE_TAG
设置为-x64
,因此它正在搜索boost库名称,例如:
It is not setting the _boost_ARCHITECTURE_TAG
for MinGW
to -x64
, so it is searching for boost library names like:
libboost_system-mgw73-mt-d-1_69.a
代替:
libboost_system-mgw73-mt-d-x64-1_69.a
有一种解决方法:将cmake
变量:Boost_ARCHITECTURE
设置为-x64
.
There is a workaround: set the cmake
variable: Boost_ARCHITECTURE
to -x64
.
注意:将Boost_ARCHITECTURE
设置为环境变量无效,因为FindBoost.cmake
不会将Boost_ARCHITECTURE
读取为环境变量.
Note: setting Boost_ARCHITECTURE
as an environment variable does not work, as FindBoost.cmake
does not read Boost_ARCHITECTURE
as an environment variable.