Does it really hard to build Boost libraries with MinGW compiler on Windows?
I have the Windows version Boost library build for Microsoft compiler, when I tried to link them in QT creator, as shown below, was failed even though I have configured the build kit to the Microsoft compiler in QT creator.
win32 {
INCLUDEPATH += C:/Tool/boost_1_54_0
LIBS += -LC:/Tool/boost_1_54_0/lib64-msvc-11.0 -lboost_filesystem-vc110-1_54
}
Looking on the Internet, the majority of them are using
MinGW version of Boost library whenever working on QT, not the Microsoft version. To build a
MinGW version of Boost, it wasn't that straight forward as following command.
c:\tool\boost_1_54_0>bootstrap.bat
c:\tool\boost_1_54_0>b2.exe --toolset=gcc
I did try on the command mention above, but end up nothing were being generated in
stage/lib. I then found there is a workaround for building the MinGW version of Boost:
Step 1
Go to
<BOOST_ROOT>/tools/build/v2/engine, and fire the command:
build.bat mingw. This will generate
bin.ntx86 folder under the same path.
Step 2
Set environment variable:
set PATH=%PATH%;<BOOST_ROOT>/tools/build/v2/engine/bin.ntx86. Without this Windows will not recognize who is
bjam.
Step 3
Set environment variable:
set PATH=%PATH%;<MinGW_ROOT>/bin. Without this the compiler will not recognize who is
gcc.
Step 4
Fire the command:
bjam toolset=gcc. This should generate a bunch of libraries with file name that contain
mgw with
.a extension.
One last note, bjam command will require
mingw32-libz to be installed with MinGW compiler before Boost is start building. Once done, reconfigure the
.pro file with following code:
win32 {
INCLUDEPATH += C:/Tool/boost_1_54_0
LIBS += -LC:/Tool/boost_1_54_0/stage/lib -lboost_filesystem-mgw48-mt-1_54
}