### Author Topic: Configuring Boost with Code::Blocks  (Read 58851 times)

#### aaronds

• Single posting newcomer
• Posts: 5
##### Configuring Boost with Code::Blocks
« on: August 24, 2011, 04:00:35 pm »
Hi,

I've never configured an external library with a C/C++ IDE before so this is all new to me. I'm looking to configure the Boost library with Code::Blocks (windows, MinGW) but I just can't get it working. I have built and installed the Boost library, I just need to configure it with my project. I have of course consulted the documentation but it appears to be some what out of date, as it uses Boost 1.42 (I'm using 1.47). The documentation talks about include and lib folders, neither of which are in my installation.

So far, I have set up a global variable in the IDE called "boost" that links to the base directory of the boost installation as the base field (under builtin fields) and links to the boost/ subdirectory as the include field. Within the build options for my project, under search directories, I have set the compiler directory to the boost subdirectory within the boost installation folder, while I have also set the linker directory to the stage folder.

However, I am aware that even if all that I have done so far is correct, I still need to add additional linker settings but I'm lost as to what to do here. From what I can make out in the documentation I need to link specific libraries (I'm trying to use the asio library within Boost), but I can't find anything relevent within my boost installation.

If anyone could tell me whether what I've done so far is correct or not and perhaps direct me on where I should go from here, I would be very appreciative.

Cheers

#### Alpha

• Developer
• Lives here!
• Posts: 1513
##### Re: Configuring Boost with Code::Blocks
« Reply #1 on: August 24, 2011, 07:00:35 pm »
It sounds like you have done most everything correctly so far, but just in case, I will list out several steps.

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; see this page if you need step-by-step instructions on that).
iii. In Search directories tab Linker sub-tab filed entered $(#boost.lib) #### Alpha • Developer • Lives here! • Posts: 1513 ##### Re: Configuring Boost with Code::Blocks « Reply #11 on: October 19, 2011, 01:08:46 am » d) c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.5.2\include\c++\bits\stl_algo.h:4185|2|instantiated from '_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = std::istream_iterator<int>, _Funct = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boo| 2) Used software versions a. Code::Blocks 10.05 b. MinGW 4.6 c. Boost 1.47.0 It looks like you may have two conflicting MinGW installations. (I just tested the code with 4.6; it compiled with zero warnings or errors). Note: error messages are more readable when enclosed in code tags. #### ptolomey • Multiple posting newcomer • Posts: 12 ##### Re: Configuring Boost with Code::Blocks « Reply #12 on: October 19, 2011, 11:45:29 am » Alpha thanks for advise, I have installed Qt SDK (4.7), it comes with MinGW 4.5, built inside package. I will uninstall it and try to compile above mentioned code one more time Code: [Select] #include <boost/lambda/lambda.hpp>#include <iostream>#include <iterator>#include <algorithm>int main(){ using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " );} In any case thanks for advise. I will response if succeeded or not. #### ptolomey • Multiple posting newcomer • Posts: 12 ##### Re: Configuring Boost with Code::Blocks « Reply #13 on: February 11, 2012, 02:42:17 pm » Finally I succeeded. The only mistake was in definition of CodeBlocks Search Directories of Compiler. It has to be:$(#boost.include) and NOT $(#boost) as written in Wiki http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef #### Master • Multiple posting newcomer • Posts: 53 ##### Re: Configuring Boost with Code::Blocks « Reply #14 on: April 04, 2012, 06:25:05 pm » hello all , i have the same problem getting boost to work with CB . i can compile this source code : Code: [Select] #include <boost/lambda/lambda.hpp>#include <iostream>#include <iterator>#include <algorithm>int main(){ using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " );} i used these command to compile boost : boost is extracted to F:\ and main folder address is : Code: [Select] F:\boost_1_49_0here are the commands : Code: [Select] F:\F:\ cd Boost_1_44_0F:\ Boost_1_44_0> bootstrap.batF:\ Boost_1_44_0>bjam toolset=gcc --build-type=complete stage------------------- the above didnt do any good so i wrote this and actually compiled just fine : Code: [Select] F:\ Boost_1_44_0>bjam variant=debug,release link=static address-model=32 and then Code: [Select] F:\boost_1_49_0>bjam toolset=gcc variant=debug,release link=static threading=multi address-model=32 --build-type=complete stagethen when i tried to compile a thread example : Code: [Select] #include <boost/thread.hpp>#include <iostream>void wait(int seconds){ boost::this_thread::sleep(boost::posix_time::seconds(seconds));}boost::mutex mutex;void thread(){ for (int i = 0; i < 5; ++i) { wait(1); mutex.lock(); std::cout << "Thread " << boost::this_thread::get_id() << ": " << i << std::endl; mutex.unlock(); }}int main(){ boost::thread t1(thread); boost::thread t2(thread); t1.join(); t2.join();} which failed miserably with these errors : Code: [Select] obj\Debug\main.o||In function Z6threadv':|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|18|undefined reference to _imp___ZN5boost11this_thread6get_idEv'|obj\Debug\main.o||In function main':|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|27|undefined reference to _imp___ZN5boost6thread4joinEv'|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to _imp___ZN5boost6thread4joinEv'|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to _imp___ZN5boost6threadD1Ev'|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to _imp___ZN5boost6threadD1Ev'|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to _imp___ZN5boost6threadD1Ev'|D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to _imp___ZN5boost6threadD1Ev'|F:\boost_1_49_0\boost\thread\win32\thread_data.hpp|161|undefined reference to _imp___ZN5boost11this_thread18interruptible_waitEPvNS_6detail7timeoutE'|obj\Debug\main.o||In function thread<void (*)()>':|F:\boost_1_49_0\boost\thread\detail\thread.hpp|205|undefined reference to _imp___ZN5boost6thread12start_threadEv'|||=== Build finished: 9 errors, 0 warnings (0 minutes, 49 seconds) ===| i configured CB like this : right clicked on the active project >build options >Debug>Search Directories >Compiler: added these: Code: [Select] $(#boost.include)F:\boost_1_49_0F:\boost_1_49_0\boostF:\boost_1_49_0\stage\liband under linker i added:
Code: [Select]
\$(#boost.lib)F:\boost_1_49_0\stage\libF:\boost_1_49_0\libsthen i added to the Linker section and selected all of the files in stage/libs : these are :
here is the pic :

and for the variable part :
i have this :

--------------------------
what is it that i am missing ?
a man's dream is an index to his greatness...

#### killerbot

• Lives here!
• Posts: 5242
##### Re: Configuring Boost with Code::Blocks
« Reply #15 on: April 04, 2012, 09:01:27 pm »

#### Master

• Multiple posting newcomer
• Posts: 53
##### Re: Configuring Boost with Code::Blocks
« Reply #16 on: April 04, 2012, 10:04:44 pm »
thank you , are'nt all of the libs created already ? because im sure i set up the linker to look for the libraries in the correct folder .
would you please tell me how i can build just everything ?
i assume this library is not built ? right?
a man's dream is an index to his greatness...

#### oBFusCATed

• Developer
• Lives here!
• Posts: 12737
##### Re: Configuring Boost with Code::Blocks
« Reply #17 on: April 04, 2012, 10:12:46 pm »
Master: Keep in mind that boost has they support, here we support C::B and your question is quite off topic!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

#### MortenMacFly

• Lives here!
• Posts: 9595
##### Re: Configuring Boost with Code::Blocks
« Reply #18 on: April 04, 2012, 10:14:44 pm »
what is it that i am missing ?
You miss to inspect / provide the full build log (see my sig).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

#### Master

• Multiple posting newcomer
• Posts: 53
##### Re: Configuring Boost with Code::Blocks
« Reply #19 on: April 04, 2012, 10:48:11 pm »
Master: Keep in mind that boost has they support, here we support C::B and your question is quite off topic!
yes you are right , but since it was concerned with CB in terms of configuration and again because of using a svn version , i thought there might be sth wrong with the CB svn or sth has changed that i am unware of .so basically the best place to find about this would be here to my opinion .
and googling got me here by the way , thought i could use some help with the people working daily with CB .

Quote
You miss to inspect / provide the full build log (see my sig).
here is the full build log .
Code: [Select]
http://upload.ustmb.ir/uploads/13335802852.zipThank you in advance
a man's dream is an index to his greatness...

#### killerbot

• Lives here!
• Posts: 5242
##### Re: Configuring Boost with Code::Blocks
« Reply #20 on: April 04, 2012, 10:52:07 pm »
thank you , are'nt all of the libs created already ? because im sure i set up the linker to look for the libraries in the correct folder .
would you please tell me how i can build just everything ?
i assume this library is not built ? right?
telling where the libraries are is not enough, you need to tell the linker to which ones one to link.

#### Master

• Multiple posting newcomer
• Posts: 53
##### Re: Configuring Boost with Code::Blocks
« Reply #21 on: April 04, 2012, 11:06:19 pm »
thank you , are'nt all of the libs created already ? because im sure i set up the linker to look for the libraries in the correct folder .
would you please tell me how i can build just everything ?
i assume this library is not built ? right?
telling where the libraries are is not enough, you need to tell the linker to which ones one to link.
how am i supposed to that ? have i not already done that ? (in linker section (in both debug and release ) i selected all of built libs and .a files !
a man's dream is an index to his greatness...

#### Master

• Multiple posting newcomer
• Posts: 53
##### Re: Configuring Boost with Code::Blocks
« Reply #22 on: April 05, 2012, 05:26:43 am »
ok i believe i compiled all necessary libs ( they are now more than 4Gigabyte !)
here are the screen shots of my settings . its all i have done to the CB at the moment . :

what is wrong with it ?
a man's dream is an index to his greatness...

#### MortenMacFly

• Lives here!
• Posts: 9595
##### Re: Configuring Boost with Code::Blocks
« Reply #23 on: April 05, 2012, 06:30:57 am »
what is wrong with it ?
You still did not post the full build log. So I cannot tell.

From the screenshots I see that you link against all boost libs, this will not work, too. Boost compiles in many flavours. You need to pick one flavour of your choice and then only link against those lib(s) you are actually using, not just all.

Probably you should start reading the boost manual - it seems you don't really know what you are doing. We don't provide boost support here, this is a Code::Blocks forum. Boost has its own forum. You need to know what lib you need to use in what flavour. Tat's a decision I nobody make for you, as it depends on what you have in mind with your project.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

#### Master

• Multiple posting newcomer
• Posts: 53
##### Re: Configuring Boost with Code::Blocks
« Reply #24 on: April 05, 2012, 06:35:59 am »
what is wrong with it ?
You still did not post the full build log. So I cannot tell.

From the screenshots I see that you link against all boost libs, this will not work, too. Boost compiles in many flavours. You need to pick one flavour of your choice and then only link against those lib(s) you are actually using, not just all.

Probably you should start reading the boost manual - it seems you don't really know what you are doing. We don't provide boost support here, this is a Code::Blocks forum. Boost has its own forum. You need to know what lib you need to use in what flavour. Tat's a decision I nobody make for you, as it depends on what you have in mind with your project.
thank you . and sorry for that ,
i have already posted the full build log : here it is again :
and ok . i'll try to fix that too
a man's dream is an index to his greatness...

#### oBFusCATed

• Developer
• Lives here!
• Posts: 12737
##### Re: Configuring Boost with Code::Blocks
« Reply #25 on: April 05, 2012, 08:21:14 am »
Also don't use full paths to the libraries, just their names. In the Build options -> Linker setting -> Link libraries
If I remember correctly using full paths is known to fail.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

#### Master

• Multiple posting newcomer
• Posts: 53
##### Re: Configuring Boost with Code::Blocks
« Reply #26 on: April 05, 2012, 11:03:14 pm »
Also don't use full paths to the libraries, just their names. In the Build options -> Linker setting -> Link libraries
If I remember correctly using full paths is known to fail.
thank you dear oBFusCATed , i tested your suggestion , but it turned up that it was wrong . actually there is nothing wrong with the full path .
here is the answer though :
http://stackoverflow.com/questions/10022706/having-issue-in-configuring-boost-with-codeblocks/10035917#10035917
i rebuilt the boost with
Code: [Select]
bjam toolset=gcc --build-type=complete stage variant=debug,release threading=multi link=static and then added the following line to my source code
Code: [Select]
#define BOOST_THREAD_USE_LIBand there it goes compiling , linking just fine
and i didnt change any of my previouse configurations , just rebuilt and added that line , done
thanks again everyone
a man's dream is an index to his greatness...

#### GigaGerard

• Single posting newcomer
• Posts: 4
##### Re: Configuring Boost with Code::Blocks
« Reply #27 on: December 22, 2015, 10:26:36 pm »
How to get Boost working in CodeBlocks with GCC
and get the test file of Alpha in post 2 running?
I did it!
Advice that helped me most was:

Change the word msvc to gcc in the boost file project-config.jam and run b2 to compile boost (again).

Not only set the two paths in CodeBlocks > Settings > Global Variables > Build-in fields:
> base > C:\MY_DIR\boost_1_56_0\
> lib > C:\MY_DIR\boost_1_56_0\stage\lib

But also set them in CodeBlocks > Settings > Compiler > Search directories