在Windows上使用MinGW进行构建时,cmake FindBoost找不到Boost库 [英] cmake FindBoost not finding Boost libraries when building with MinGW on Windows

查看:803
本文介绍了在Windows上使用MinGW进行构建时,cmake FindBoost找不到Boost库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

qtcreator支持qmakecmake进行跨平台开发和 qmake对于在Windows上构建的msvcMinGW都可以正常工作.但是,我只想支持一种工具: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.txtlinux上以及使用时都可以正常工作cmakeWindows上构建msvc. 但是,当使用cmakeWindows上构建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_LIBRARYDIRBOOST_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.

这篇关于在Windows上使用MinGW进行构建时,cmake FindBoost找不到Boost库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆