How to install Boost libraries with CodeBlocks?

GarrickW picture GarrickW · Jul 31, 2011 · Viewed 10.1k times · Source

So I'm about at the end of my line here; I was looking into saving files and serialization, only to learn that C++ doesn't have the kind of native serialization ability that Python has with its wonderful pickle. But luckily, it has Boost - so began my quest to install Boost 1.47 on my system, in order to be able to serialize my objects.

So far, though, no success. I first thought I could use this: http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef , but I continually got mismatched version errors, and after trying multiple times to locate a Boost Jam compatible with 1.47 (I only found 1.3.19, which seems to be built for 1.46), I saw the page was over a year and a half out of date.

Then, after much searching, I was pointed here: http://www.boost.org/doc/libs/1_47_0/doc/html/bbv2/installation.html . But this doesn't work either. When running \bootstrap.bat, I get the following error:

Failed to build Boost.Build engine. Please consult bootstrap.log for further diagnostics.

Huh - well, nowhere is there a .log file of any sort, but there is a text file called bootstrap, which contains the following:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.
###
### Using 'vc10' toolset.
###

c:\Program Files (x86)\CodeBlocks\MinGW\downloaded\boost_1_47_0\tools\build\v2\engine>if exist bootstrap rd /S /Q bootstrap 

c:\Program Files (x86)\CodeBlocks\MinGW\downloaded\boost_1_47_0\tools\build\v2\engine>md bootstrap 

c:\Program Files (x86)\CodeBlocks\MinGW\downloaded\boost_1_47_0\tools\build\v2\engine>cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib /Febootstrap\jam0  command.c compile.c debug.c execnt.c expand.c filent.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c newstr.c option.c output.c parse.c pathunix.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c md5.c pwd.c class.c w32_getreg.c native.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c 
command.c
compile.c
debug.c
execnt.c
execnt.c(29) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
expand.c
filent.c
glob.c
hash.c
hdrmacro.c
headers.c
jam.c
jam.c(581) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
jambase.c
jamgram.c
lists.c
make.c
make1.c
newstr.c
option.c
output.c
parse.c
Generating Code...
Compiling...
pathunix.c
pathunix.c(275) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
regexp.c
rules.c
scan.c
search.c
subst.c
timestamp.c
variable.c
modules.c
strings.c
filesys.c
builtins.c
md5.c
pwd.c
class.c
w32_getreg.c
w32_getreg.c(18) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
native.c
set.c
path.c
regex.c
Generating Code...
Compiling...
property-set.c
sequence.c
order.c
Generating Code...

Now, I'm really just confused. I'm in way over my head with all this - I'm still programming side-scrollers and have only been C++ capable for a few months now. I don't have a clue what I am doing wrong. Can someone point me to a clear, complete step-by-step guide or something? I only want to get Boost onto my system!

Answer

Nicola Musatti picture Nicola Musatti · Jul 31, 2011

From the error message you posted I assume you're using some version of Visual Studio. In order to use its compiler from the command line you need to define a few environment variables. This is done automatically for you if you use the Visual Studio command prompt. Better yet you might want to try and follow this tutorial.