Author Topic: Configuring Boost with Code::Blocks  (Read 36655 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: 1491
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: 1491 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_0 F:\ Boost_1_44_0> bootstrap.bat F:\ 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_0
F:\boost_1_49_0\boost
F:\boost_1_49_0\stage\lib
Code: [Select]
\$(#boost.lib)
F:\boost_1_49_0\stage\lib
F:\boost_1_49_0\libs
then 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...