Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Boost libraries with CodeBlocks?

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!

like image 678
GarrickW Avatar asked Jul 31 '11 14:07

GarrickW


2 Answers

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.

like image 107
Nicola Musatti Avatar answered Nov 12 '22 07:11

Nicola Musatti


I tried following from http://forums.codeblocks.org/index.php?topic=15164.0 & it worked wonderfully.

BOOST INSTALLATION:

Download either the zip or the 7zip package of boost. Extract the contents to extract_dir.

Open Command Prompt (cmd.exe) and navigate to extract_dir. cd extract_dir

If the minGW\bin folder (can be found in CodeBlocks installatoin folder) is not in the path variable add it.

path minGW_dir\bin;%path%

Build the boost build system by entering

bootstrap.exe mingw

Open the file extract_dir\project-config.jam in Notepad and change the word msvc to gcc.

Back in the Command Prompt window, run

b2.exe

SETTING UP BOOST WITH CODEBLOCKS

Create the global variable boost with extract_dir as the base. (This is C:\Libraries\boost_1_47_0 on my computer.) The other fields do not need anything (except possibly lib; if you used a custom directory while building boost, put the path here). Next (assuming you are starting a project, not adding to an existing one), create a new project (a console app should be fine) In this project, open Project->Build options... and ensure that the overall name of the project is selected in the left-hand column (for example, boost_test). Switch to the Search directories tab and click Add (for the Compiler tab). In the box, type $(#boost) and click OK.

like image 38
hr37 Avatar answered Nov 12 '22 06:11

hr37