Tuesday, April 5, 2011

Using boost static libraries with CodeBlocks

Hi,

Since the past two days , i was trying to run the most trivial multi threading code snippet using boost thread library.

And was unsuccessful, but failure is not always negative , it provided me with the matter for a new blog post to share :)

The issue i was facing was , when i built the project using dynamic boost libraries it worked fine, but as i didn't wanted to have to provide the libraries separately, i tried building the project with statically linked libraries, but no matter what i tried, build always failed with unreferenced symbol error.

Tried re downloading the boost code and recompiling it after a detailed study of bjam build option, but everything failed, then i found , hidden under the pile of junk on the internet a single line of code , and everything was working.

I'll stop being poetic and post the code below.

#define BOOST_THREAD_USE_LIB

Just add this line at the top of the source file using the library and u'll be fine.

As it turned out, the problem was with codeblocks build system, the headers being used were expecting the library to get linked dynamically , atleast this is what i was able to under stand.

So, now i can move along on an adventurous voyage of exploring the boost underworld.
Will keep you all posted.

Regards,
Ishan.

No comments:

Post a Comment