How do I build Boost libraries on Code::Blocks (Wi

2019-04-15 06:02发布

问题:

Ugh, I'm tired. All of my searches on the matter have been in vain. No matter how many solutions I find, I just cannot find a way to build Boost's libraries.

So, I can simply throw the 'boost' root directory into Code Block's 'include' and skip building the majority of libraries. How do I, then, build separately the non-header-only libraries?

Please, mind you that I'm a complete layman towards .bat, cmd, all this stuff. Even if anything I tried of the supposed solutions I've found already actually could work, I just cannot make head or tails of anything that is actually instructed.

Man, I just want to be able to use boost::thread's. :I

回答1:

"How do I, then, build separately the non-header-only libraries?"

If you are using MinGW for example as your compiler choice then open up a command prompt, navigate to the boost root directory that you downloaded/extracted and run the bootstrap.bat command in the following manner:

bootstrap.bat mingw

b2.exe

Running the bootstrap command will generate the MinGW-related library files (defaulting to the stage/lib subdirectory) that you will need to link to within Code::Blocks, which will include the one you needed for Boost.Threads for example:

And then in CodeBlocks you will need to

  1. Set the location of the Boost root directory in the Search
  2. Select the Linker tab and set the location of the library files
  3. Select the Linker Settings tab add the necessary library names eg

See this link for more screenshots and explanations:

http://www.technical-recipes.com/2014/configuring-codeblocks-to-use-the-boost-libraries/



回答2:

Here's the guide: BoostWindowsQuickRef, but the first half may be a bit confusing and outdated.

  • unpack boost into a separate directory of you choice (i.e C:\boost_1_52_0, don't just throw it into the code::blocks include dir)
  • make sure you can run gcc from your windows command line:

    C:\> gcc --version
    gcc (GCC) 4.6.2
    

    If this step fails, you have to add <mingw installation dir>\bin to your path environment variable:

    c:\> PATH=%PATH%;C:\PathToMinGW\bin
    
  • run bootstrap with gcc as argument to build the boost.build engine with gcc:

    C:\boost_1_52_0> bootstrap.bat gcc
    
  • run bjam and specify the toolset, in this case also gcc, to build the libraries:

    C:\boost_1_52_0> b2.exe toolset=gcc
    
  • Follow the guide Add Boost to an existing project in Code::Blocks on how to setup code::blocks for boost.



标签: c++ boost