Author Topic: [solved] Linking with Boost 1_51_0 Windows7  (Read 7602 times)

Attila009

  • Guest
[solved] Linking with Boost 1_51_0 Windows7
« on: August 27, 2012, 11:46:16 pm »
I just want to share the mistakes I did linking Boost 1_51_0 with Codeblocks10.05+MiniGW(gcc) and lost therefore 20 hours the recent days.

To Build Boost 1_51_0 under Windows see this guide under section 5.3:
http://www.boost.org/doc/libs/1_51_0/more/getting_started/windows.html
If you use gcc like me don't forget to mention it to the commands like "bootstrap.bat gcc" or with the "toolset" command.

Above 3 lines look short, but if you are new to it, like I was, it will take you some hours. The building of Boost itself will take at least 20 minutes.

Now link Boost to Codeblocks, you will find lots of information via google, but lots of it is crap and/or old.

First the global Variables.


You will find the dialog above under Settings->Global Variables...

Basically you tell codeblocks whenever there is #boost it is actually the path "C:\Programmieren\boost_1_51_0" in my case.
And #boost.lib is "C:\Programmieren\boost_1_51_0\stage\lib". I had some trouble with #boost.include, if you got the point how it works you can decide yourself if you want to write something there or leave the field blank.

Now you use the Global Variable "#boost" to tell codeblocks the path for compiling and linking.


You find this dialog like this. Right-click on your project->Build options... Now click on the root of your project, e.g. neither click on debug nor on release. Select "Search directories" and then "Compiler" tab. Here you tell the path of your header files. What to write here depends on what you have written as global variables and what you will write in your projects. For example you have "#include <boost\regex.hpp>" in your *.cpp file then you will have to write $(#boost) in the compiler tab. Because $(#boost) is "C:\Programmieren\boost_1_51_0" and when you include "boost\regex.hpp" it will be the path "C:\Programmieren\boost_1_51_0\boost\regex.hpp" and there is the regex.hpp!

And don't do the mistake I did "$(#boost)" <---NO BLANKS HERE (or it will cost you hours of debugging).

The same for the Linker.

Remember, what "#boost.lib" is you told codeblocks in the "Global variables..." Dialog.(see above)

Last step linker settings.


Here you have to link the binarys of the librarys. The tab is just on the left side of the "search directories" tab.(see above)
In my case the librarys are in "C:\Programmieren\boost_1_51_0\stage\lib". And if you want to link regex you have to choose one of those files:


The explanation for the library names you will find in this guide under section 6.3:
http://www.boost.org/doc/libs/1_51_0/more/getting_started/windows.html

I decidet to link "libboost_regex-mgw44-1_51.a" and it went well!

This is the end! And it works!

thistleknot

  • Guest
Re: [solved] Linking with Boost 1_51_0 Windows7
« Reply #1 on: October 12, 2012, 10:58:55 am »
F:\CodeBlocks\include\boost\thread\detail\thread.hpp|186|undefined reference to `boost::thread::start_thread()'|

solved
in codeblocks, this fixed it

settings
compiler & debugger
linker settings
add

F:\CodeBlocks\lib\libboost_regex-mgw44-1_51.a
F:\CodeBlocks\lib\libboost_thread-mgw44-mt-1_51.a
F:\CodeBlocks\lib\libboost_chrono-mgw44-1_51.a
f:\codeblocks\lib\*.a

depends on libraries needed, which depends on your #includes
« Last Edit: October 12, 2012, 11:36:58 am by thistleknot »

Offline cacb

  • Lives here!
  • ****
  • Posts: 539
Re: [solved] Linking with Boost 1_51_0 Windows7
« Reply #2 on: October 13, 2012, 10:08:10 am »
in the linker settings, you should remove the path with the library name. It is already specified in the global variable via $(#boost.lib)

For the include path I would either use $(#boost.include), which means you must include the base path in the include field when defining the global variable. An alternative is to use $(#boost.base), which is imilar to what you have done I guess.