Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
827 views
in Technique[技术] by (71.8m points)

c++ - cmake FindBoost not finding Boost libraries when building with MinGW on Windows

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.

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:

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.

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

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

Is this a bug in FindBoost.cmake? Is there a "work around"?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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

instead of:

libboost_system-mgw73-mt-d-x64-1_69.a

There is a workaround: set the cmake variable: Boost_ARCHITECTURE to -x64.

Note: setting Boost_ARCHITECTURE as an environment variable does not work, as FindBoost.cmake does not read Boost_ARCHITECTURE as an environment variable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...