1
votes

So, I have to ask very noobish question, but I have been scrambling all over the Internet and I can't seem to find the anwser.

So, I decided to use Boost with Code::Blocks. I used BoostPro Installer and installed the latest version, which is 1.51.0.

So, directory where my Boost folder is located is :

C:/Program files/boost

That directory also contains one folder within it, so it's like this :

C:/Program files/boost/boost_1_51

So, my question is, how do setup my Code::Blocks so it can work. I did the following :

Went to Settings > Global Variables, created a new one called boost.

Set it's base to : C:\Program Files\boost\boost_1_51

Set it's include to : C:\Program Files\boost\boost_1_51\boost

Then, I went to my project, right-clicked it > Build Options > highlighted my root project > Search Directories.

Then, under my Compiler sub-tab, I clicked Add and added this :

$(#boost.include)

Under Linker sub-tab, I clicked Add and added this :

$(#boost.lib)

And I can't seem to compile sample code (located on official Boost web-site > Getting started).

Thanks in advance!

2
Doesn't BoostPro Installer only provide VC++ binaries? Are you using VC++ with code blocks? If not, it won't work. - Jesse Good
OK, so what do I have to do now? - TheGhost
Download the boost source and build it with the compiler you are using yourself. - Jesse Good
OK, just to ask, how to do it? - TheGhost
Read the getting started page, I also provided an answer here. Code blocks also has a tutorial here. - Jesse Good

2 Answers

2
votes

The CodeBlocks wiki has instructions on setting up boost: http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef

In particular, for building boost from source, look at the Build Boost section and make sure to choose the correct toolset (in your case, I assume it would be --toolset=gcc when using MinGW).

1
votes

In order to use Filesystem, I used another computer, and performed the following steps, and it worked:

1) Installed MinGW
2) Added this enviroment variable => C:\MinGW\bin
3) bootstrap.bat gcc
4) b2 install --prefix="C:\Boostbuild" --toolset=gcc
5) Added this enviroment variable => C:\Boostbuild\bin
6) b2 --build-dir="C:\Boostbuild" toolset=gcc --build-type=complete stage
7) Installed CodeBlocks without MinGW
CodeBlocks:
8) Settings->Global variables: current variable => boost, Base => C:\boost_1_53_0, include => C:\boost_1_53_0\stage\lib
9) On the new C++ console project:
Build Options->Choose Project Name on the left -> search directories
On compiler tab, press Add and type: $(#boost)
On linker tab, press Add and type: $(#boost.lib)
10) On the new C++ console project:
Build Options->Choose Project Name on the left -> linker settings
Add the following link libraries:
..\..\boost_1_53_0\stage\lib\libboost_filesystem-mgw46-mt-1_53.a
..\..\boost_1_53_0\stage\lib\libboost_system-mgw46-mt-1_53.a

Thanks everybody