configuring boost with code__blocks

12
Code::Blocks Welcome, Guest. Please login or register. Did you miss your activation email ? Forever Login Login with username, password and session length Search News: The new Release 13.12 is out! You can download binaries for windows, mac and many major linux distros from http://www.codeblocks.org/downloads/26 . Code::Blocks » User forums » Help » Configuring Boost with Code::Blocks SEND THIS TOPIC PRINT Pages: [1] 2 All Go Down aaronds 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 Logged Alpha Developer Lives here! 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. « previous next » Author Topic: Configuring Boost with Code::Blocks (Read 26550 times) Home Help Search Login Register Wiki Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0 1 of 12 2/26/2015 7:52 PM

Upload: chase

Post on 14-Nov-2015

34 views

Category:

Documents


2 download

DESCRIPTION

Cofigure Boost with Code::BlocksThis contains information on how to configure Boost C++ Libraries on Code::Blocks, a cross-platform, open-source C++ IDEThis pdf was printed from forums.codeblocks.org, displayed here for instructional purposes only. No copyright infringement intended.

TRANSCRIPT

  • Code::Blocks

    Welcome, Guest. Please login or register.Did you miss your activation email?

    Forever Login

    Login with username, password and session length

    Search

    News:The new Release 13.12 is out! You can download binaries

    for windows, mac and many major linux distros fromhttp://www.codeblocks.org/downloads/26 .

    Code::Blocks User forums Help Configuring Boost with Code::Blocks

    SEND THIS TOPIC PRINTPages: [1] 2 All Go Down

    aarondsNewcomer

    Posts: 5

    Configuring Boost withCode::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 isall 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 installedthe Boost library, I just need to configure it with my project. I have ofcourse consulted the documentation but it appears to be some what out ofdate, as it uses Boost 1.42 (I'm using 1.47). The documentation talks aboutinclude 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 tothe base directory of the boost installation as the base field (under builtinfields) and links to the boost/ subdirectory as the include field. Within thebuild options for my project, under search directories, I have set thecompiler directory to the boost subdirectory within the boost installationfolder, 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 stillneed 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 specificlibraries (I'm trying to use the asio library within Boost), but I can't findanything relevent within my boost installation.

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

    Cheers

    Logged

    AlphaDeveloperLives here!

    Re: Configuring Boost withCode::Blocks

    Reply #1 on: August 24, 2011, 07:00:35 pm

    It sounds like you have done most everything correctly so far, but just incase, I will list out several steps.

    previous next

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

    Home Help Search Login Register Wiki

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    1 of 12 2/26/2015 7:52 PM

  • Posts: 1442

    Last Edit: August 24, 2011, 08:11:21 pm by Alpha

    Create the global variable boost with extract_dir as the base. (This isC:\Libraries\boost_1_47_0 on my computer.) The other fields do not needanything (except possibly lib; if you used a custom directory while buildingboost, 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 needstep-by-step instructions on that).In this project, open Project->Build options... and ensure that the overallname of the project is selected in the left-hand column (for example,boost_test). Switch to the Search directories tab and click Add (for theCompiler tab). In the box, type $(#boost) and click OK.Many features of boost do not require any libraries, (asio included). Here isa list of what does require linking.(Edit:) Asio depends on Boost.System and may need Boost.Regex andOpenSSL depending on what you are doing.To test the current configuration, put this (from here) in the main cpp.Code: [Select]

    #include

    #include

    #include

    #include

    int main()

    {

    using namespace boost::lambda;

    typedef std::istream_iterator in;

    std::for_each(

    in(std::cin), in(), std::cout

  • Last Edit: August 24, 2011, 10:17:43 pm by aaronds

    reference errors you talked about. In order to check whether this was due toa linker error, I linked all the available libraries (from the stage folder) butthe errors persist (they're coming from error_code.hpp). Really not sure whyI haven't been able to resolve this :S

    Thanks again

    Logged

    AlphaDeveloperLives here!

    Posts: 1442

    Re: Configuring Boost withCode::Blocks

    Reply #3 on: August 25, 2011, 12:20:10 am

    Did the minimal code sample I provided compile?Also, go to Settings->Compiler and debugger...->Build options (tab) andcheck Save build log and Always output the full command line. If you postthe log here (it should be generated in the project's directory each time youcompile), I might be able to see what is going wrong.

    Quote from: aaronds on August 24, 2011, 04:00:35 pm

    I have built and installed the Boost library, I just need to configure it with my project.

    Quote from: aaronds on August 24, 2011, 10:07:37 pm

    My boost installation doesn't have a lib folder

    I assume from this the build succeded, so there should be multiple lib*.afiles somewhere on your harddrive - the default folder is lib, however, itseems they have gone somewhere else on your computer. Locate this folderand add it to the linker search directories.

    Logged

    aarondsNewcomer

    Posts: 5

    Re: Configuring Boost withCode::Blocks

    Reply #4 on: August 25, 2011, 01:03:40 am

    Quote from: Alpha on August 25, 2011, 12:20:10 am

    Did the minimal code sample I provided compile?

    The code example appears to compile, but it doesn't output anything to theCMD window (it just seems to hang...?).

    Quote from: Alpha on August 25, 2011, 12:20:10 am

    I assume from this the build succeded, so there should be multiple lib*.a files somewhere onyour harddrive - the default folder is lib, however, it seems they have gone somewhere elseon your computer. Locate this folder and add it to the linker search directories.

    I have a range of .lib files but not .a. When I built boost I didn't receive anyerrors and as far as I know the build was successful. However, I don't have a/lib/ folder, only /libs/ and /stage/lib/. I believe the output of the build wasto /boost/bin.v2/libs (all directories created during the build). I didn't seeanything else created. Maybe this is where the problem is...?

    Logged

    AlphaDeveloperLives here!

    Re: Configuring Boost withCode::Blocks

    Reply #5 on: August 25, 2011, 03:05:56 am

    Quote from: aaronds on August 25, 2011, 01:03:40 am

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    3 of 12 2/26/2015 7:52 PM

  • Posts: 1442

    Last Edit: August 25, 2011, 03:58:01 pm by Alpha

    The code example appears to compile, but it doesn't output anything to the CMD window (itjust seems to hang...?).

    Oh, I should have mentioned all it does is multiply the input number by 3(you need to type a number and press enter).

    Quote from: aaronds on August 25, 2011, 01:03:40 am

    Quote from: Alpha on August 25, 2011, 12:20:10 am

    I assume from this the build succeded, so there should be multiple lib*.a files somewhereon your harddrive - the default folder is lib, however, it seems they have gonesomewhere else on your computer. Locate this folder and add it to the linker searchdirectories.

    I have a range of .lib files but not .a. When I built boost I didn't receive any errors and as far asI know the build was successful. However, I don't have a /lib/ folder, only /libs/ and /stage/lib/.

    Sorry, I apparently was not thinking when I replied previously; /stage/lib/is the default folder (not lib).

    I think the overall problem is that the library ws2_32 needs to be added tothe linker. Your build configuration does sound slightly different than mine,so if adding this library (as well as keeping the other necessary libraries)does not fix the problem, use the following steps to rebuild boost fromscratch.

    Download either the zip or the 7zip package from this page. Extract thecontents to extract_dir.

    Open Command Prompt (cmd.exe) and navigate to extract_dir.cd extract_dir

    If the minGW\bin folder is not in the path variable add it.path minGW_dir\bin;%path%

    Build the boost build system by enteringbootstrap mingw

    Open the file extract_dir\project-config.jam in Notepad and change theword msvc to gcc.

    Back in the Command Prompt window, runb2

    If it still does not work, post a build log.Quote from: Alpha on August 25, 2011, 12:20:10 am

    go to Settings->Compiler and debugger...->Build options (tab) and check Save build log andAlways output the full command line.

    Logged

    aarondsNewcomer

    Posts: 5

    Re: Configuring Boost withCode::Blocks

    Reply #6 on: August 25, 2011, 05:44:59 pm

    Hi, I've just rebuilt boost and it looks a bit more promising. I hadn'tconfigured the build to compile with MinGW previously (it had still builtthough). I'll edit once I try to build a project.

    Quote from: Alpha on August 25, 2011, 03:05:56 am

    Quote from: aaronds on August 25, 2011, 01:03:40 am

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    4 of 12 2/26/2015 7:52 PM

  • Last Edit: August 25, 2011, 08:32:46 pm by aaronds

    The code example appears to compile, but it doesn't output anything to the CMDwindow (it just seems to hang...?).

    Oh, I should have mentioned all it does is multiply the input number by 3 (you need to type anumber and press enter).

    My bad, I only scan-read the code quickly before running it.

    Edit:

    Seem much closer than before. One last error to get rid of when attemptingto use asio.Code: [Select]

    undefined reference to `WSACleanup@8

    undefined reference to `WSACleanup@0

    Both errors originate from winsock_init.ipp. I've tried linking a few libraries(this time I have the .a files, one of the libs I tried linking was system) but Ihaven't resolved the issue.

    Quote from: Alpha on August 24, 2011, 07:00:35 pm

    If in working you ever come up with an undefined reference error, it will usually indicate alibrary does need to be linked. In this case, return to the main project's search directoriessettings, but this time on the Linker tab. Add $(#boost)\lib (or $(#boost.lib) if you setup the lib variable); this should point to the directory with all the lib*.a files.After this, go to the Linker settings tab and add (using the Add button of course) the neededlibrary or libraries. (For example, boost_filesystem for the Boost.Filesystem library -basically the name of the file minus the lib and the .a.)

    I don't have any .a file that has asio in the name.

    Quote from: aaronds on August 25, 2011, 01:03:40 am

    If it still does not work, post a build log.Quote from: Alpha on August 25, 2011, 12:20:10 am

    go to Settings->Compiler and debugger...->Build options (tab) and check Save build logand Always output the full command line.

    I don't seem to have a build options tab :S

    Thanks again for your help.

    Logged

    AlphaDeveloperLives here!

    Posts: 1442

    Re: Configuring Boost withCode::Blocks

    Reply #7 on: August 25, 2011, 11:26:40 pm

    Quote from: aaronds on August 25, 2011, 05:44:59 pm

    One last error to get rid of when attempting to use asio.Code: [Select]

    undefined reference to `WSACleanup@8

    undefined reference to `WSACleanup@0

    Both errors originate from winsock_init.ipp. I've tried linking a few libraries (this time I have the.a files, one of the libs I tried linking was system) but I haven't resolved the issue.

    Quote from: Alpha on August 25, 2011, 03:05:56 am

    I think the overall problem is that the library ws2_32 needs to be added to the linker.

    As you seem to have found, asio (on Windows) requires the WindowsSockets API; support for it can be added by linking to the library ws2_32 (itis included in minGW, so you do not need to find it).

    Quote from: aaronds on August 25, 2011, 05:44:59 pm

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    5 of 12 2/26/2015 7:52 PM

  • Last Edit: September 01, 2011, 11:10:37 pm by Alpha

    I don't have any .a file that has asio in the name.

    That is because asio does not have a library, it just requires theBoost.System library (and the Winsock library).

    Quote from: aaronds on August 25, 2011, 05:44:59 pm

    I don't seem to have a build options tab :S

    See if this screenshot helps. (The arrows scroll the tabs left and right, sothe Build options tab may not be visible at first.)

    Logged

    aarondsNewcomer

    Posts: 5

    Re: Configuring Boost withCode::Blocks

    Reply #8 on: August 28, 2011, 04:49:47 pm

    Hi Alpha, sorry I was away for a few days. Thanks very much for your help, Igot boost configured and working fine!Thanks again

    Logged

    AlphaDeveloperLives here!

    Posts: 1442

    Re: Configuring Boost withCode::Blocks

    Reply #9 on: August 28, 2011, 11:11:12 pm

    Glad to be of assistance (and that it worked). If you feel comfortableenough with it, you might consider updating the boost page on theCode::Blocks wiki. (If not, I probably will when I get around to it.)

    Logged

    ptolomeyAdvanced newcomer

    Posts: 12

    Re: Configuring Boost withCode::Blocks

    Reply #10 on: October 18, 2011, 07:04:43pm

    I have problems with Code::Blocks configuration for Boost.

    Description of problem:

    1. During compilation of code supplied by Alpha, following error messagesare appear (have no compilation problems if not using Boost) a) C:\Program Files\CodeBlocks\Boost\include\boost-1_47\boost\lambda\detail\lambda_functor_base.hpp|227| [ skipping 6 instantiationcontexts ]|

    b) C:\Program Files\CodeBlocks\Boost\include\boost-1_47\boost\lambda\detail\operator_lambda_func_base.hpp:60|56|instantiated from'boost::lambda::detail::binary_rt

  • inherited::sig::typeboost::lambda::lambda_functor::operator()(const A&) const [with A= int, T =boost::lambda::lambda_functor_base
  • Files\CodeBlocks\Boost\include\boost-1_47 iv. In field lib entered following path: C:\Program Files\CodeBlocks\Boost\lib

    5. Setting Code::Blocks Project Build Options a. In Project->Build options... i. Ensured that the overall name of the project is selected in theleft-hand column ii. In Search directories tab Compiler sub-tab filed entered$(#boost) iii. In Search directories tab Linker sub-tab filed entered$(#boost.lib)

    Logged

    AlphaDeveloperLives here!

    Posts: 1442

    Re: Configuring Boost withCode::Blocks

    Reply #11 on: October 19, 2011, 01:08:46am

    Quote from: ptolomey on October 18, 2011, 07:04:43 pm

    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, _Funct =boost::lambda::lambda_functor

  • I will response if succeeded or not.

    Logged

    ptolomeyAdvanced newcomer

    Posts: 12

    Re: Configuring Boost withCode::Blocks

    Reply #13 on: February 11, 2012, 02:42:17pm

    Finally I succeeded.The only mistake was in definition of CodeBlocks Search Directories ofCompiler.It has to be: $(#boost.include) and NOT $(#boost) as written in Wikihttp://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef

    Logged

    MasterAdvanced newcomer

    Posts: 53

    Re: Configuring Boost withCode::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

    #include

    #include

    #include

    int main()

    {

    using namespace boost::lambda;

    typedef std::istream_iterator in;

    std::for_each(

    in(std::cin), in(), std::cout 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 thenCode: [Select]

    F:\boost_1_49_0>bjam toolset=gcc variant=debug,release link=static threading=multi address-model=32

    then when i tried to compile a thread example :Code: [Select]

    #include

    #include

    void wait(int seconds)

    {

    boost::this_thread::sleep(boost::posix_time::seconds(seconds));

    }

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    9 of 12 2/26/2015 7:52 PM

  • boost::mutex mutex;

    void thread()

    {

    for (int i = 0; i < 5; ++i)

    {

    wait(1);

    mutex.lock();

    std::cout

  • and for the variable part :i have this :

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    11 of 12 2/26/2015 7:52 PM

  • --------------------------what is it that i am missing ?

    Logged

    a man's dream is an index to his greatness...

    SEND THIS TOPIC PRINTPages: [1] 2 All Go Up

    Code::Blocks User forums Help Configuring Boost with Code::Blocks

    previous next

    Jump to: => Help go

    SMF 2.0.9 | SMF 2014, Simple Machines

    XHTML RSS WAP2

    Configuring Boost with Code::Blocks http://forums.codeblocks.org/index.php?topic=15164.0

    12 of 12 2/26/2015 7:52 PM