Wednesday, February 16, 2011

boost, in vista using mingw and cmd.exe

Gezz.. what a pain... Getting boost to build in mingw is a bit of a mess. The docs dont "officially" cover it, but it does work once you patch together all the various missing pieces. Here is how:

Mingw version: 4.5
Boost Version: 1.45
OS: Vista.

First Download the tar.bz version from http://sourceforge.net/projects/boost/files/boost/1.45.0/.
Dont download the build version of bjam it wont work. You need to build it.

Build bjam:
Refer: http://boost.org/doc/libs/1_45_0/doc/html/jam/building.html

Note that I use the directory c:\tools as my install area for all programs that need to avoid the windows UAE etc idiocy.. Transfer the unziped/untared files into the desired location and then build the bjam.exe

In cmd.exe execute:
cd C:\tools\boost_1_45_0\tools\build\v2\engine\src
build.bat mingw
Once built copy C:\tools\boost_1_45_0\tools\build\v2\engine\src\bin.ntx86\bjam.exe into C:\tools\MinGW\bin (makes it easy later, since you likely have it in your %PATH% var already.)

Build the boost libs In cmd.exe execute:
bjam toolset=gcc --build-type=complete stage
Refer: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#or-build-from-the-command-prompt

Wait copious amounts of time... There seems to be ALOT of warnings simply ignore them they are "harmless"

You can build boost test programs(in cmd or msys) with:
g++ -I"c:\tools\boost_1_45_0" -L"c:\tools\boost_1_45_0\stage\lib" -static boost_lamba_test.cpp -o a.exe
g++ -I"c:\tools\boost_1_45_0" -L"c:\tools\boost_1_45_0\stage\lib" -static boost_regex_test.cpp -lboost_regex-mgw45-1_45 -o b.exe

Lamba test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#build-a-simple-program-using-boost
Regex test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#link-your-program-to-a-boost-library

Keep in mind the order of the source and libs files is important in mingw
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use

1 comment:

  1. Thanks for saving me the frustrations of building boost on my own :)

    ReplyDelete