Sign in to follow this  
WindScar

How to compile boost?

Recommended Posts

I'm think an OK programmer, but I really get in trouble when it i have to compile a new library. Is it hard for everyone or is it just me? Anyway I need the boost::thread binary from boost 1_41 and I cant figure out how to compile it with MINGW. Please, help me.

Share this post


Link to post
Share on other sites
Did you read the getting started page? basically get yourself the latest pre-built binary of bjam put it in the root directory of your extracted boost files, navigate to that directory in command prompt (probably best to use MSYS-ified command prompt (not rxvt)) and then write:


bjam toolset=gcc --build-type=complete stage


This will build all types of libraries, static libraries (.a files for GCC (.lib for vc++)) both static and dynamic linking to CRT (C runtime libraries) and shared libraries/DLLs (there should also be export libraries for these shared libraries and they are also .a files). Caution you gonna need a lot of hard-drive space but this is the probably the easiest method for you.

One thing to note is when you are ready to build your source which uses boost since your boost directory is most likely not in the default directories and default search paths where GCC/MinGW looks for include and library files you will need to explicitly state where the header include and library files for boost are. GCC options for these are -I for include directories and -L for library directories. You will also need to state which libraries you want to link to, this is the -l (yes it is case senstive) option. GCC follows the convention of library files (.a) to be liblibname.a but when you specify the library to link to you just say libname instead of liblibname.a e.g. file called libfoo.a is specified to GCC as -lfoo.

If you don't want to deal with some of this kind of stuff yet then I recommend a good IDE like Code::Blocks but you still need to say where libraries (include/lib directories) are if they are not in the default directories and default search paths and you still need to state which libraries to link but it will save you some pain.

[Edited by - snk_kid on December 26, 2009 7:10:03 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by WindScar
Is it hard for everyone or is it just me?


I don't really have anything constructive to say just that you are not alone! took me ages to compile it (with bjam) but I did eventually so stick with it.

Share this post


Link to post
Share on other sites
If you really only want Boost.Thread, add --with-thread to snk_kid's command line, probably right after toolset=gcc. Typing bjam --help actually gives some pretty useful basics.

I know what you feel like; you're not alone. If it can help, I've posted a number of topics and gotten a lot of help on this subject.
Installing boost, and build confusion.
Linking Boost.Signal, wants static *and* dynamic libs.
  • boost is just a bunch of headers and source files thrown all togheter. Some utilities just need you to include the .h files, some others needs you to include some .cpp files into your project. Just add the files you need. You don't need to compile the entire thing in order to use some stuff. The compiler will tell you what you need.

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by owl
    boost is just a bunch of headers and source files thrown all togheter. Some utilities just need you to include the .h files, some others needs you to include some .cpp files into your project. Just add the files you need. You don't need to compile the entire thing in order to use some stuff. The compiler will tell you what you need.


    This isn't good advice, you should still use the build system because it will configure code for the compiler(s) and environment, even if you know the correct define you should still use the build system. Furthermore if you're dealing with software license(s) you probably want to play it safe and not link statically in your app. I'm sure boost's license is quite lenient however you may be using a license (either your own code or a library) which doesn't play nice with other licenses.

    [Edited by - snk_kid on December 27, 2009 3:54:37 AM]

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by snk_kid
    Furthermore if you're dealing with software license(s) you probably want to play it safe and not link statically in your app.


    Actually, Boost will be linked statically anyway unless you configure the automatic linking differently. Nevertheless I still suggest compiling the library properly as it simplifies things greatly in the long run.

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by BitMaster
    Quote:
    Original post by snk_kid
    Furthermore if you're dealing with software license(s) you probably want to play it safe and not link statically in your app.


    Actually, Boost will be linked statically anyway unless you configure the automatic linking differently. Nevertheless I still suggest compiling the library properly as it simplifies things greatly in the long run.


    Typically you define BOOST_ALL_DYN_LINK globally when you want to use shared library/DLLs version of boost. I'm pretty sure there are defines for specifying specific components to use shared library versions also.

    Share this post


    Link to post
    Share on other sites
    Yeah, but unless you undertake these special configuration steps, it will be linked statically. That aside, I have never found any reason to link Boost dynamically since the license is indeed very lenient and the last thing the world needs is more DLLs to keep track of for no purpose. ;)

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by snk_kid
    Quote:
    Original post by owl
    boost is just a bunch of headers and source files thrown all togheter. Some utilities just need you to include the .h files, some others needs you to include some .cpp files into your project. Just add the files you need. You don't need to compile the entire thing in order to use some stuff. The compiler will tell you what you need.


    This isn't good advice, you should still use the build system because it will configure code for the compiler(s) and environment, even if you know the correct define you should still use the build system.


    On windows I haven't experienced any troubles. On Linux, you have them already and it could be messy to upgrade them other than through your package manager.

    Still, you're right. It won't hurt you if you build them as they tell you to build them.

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    Sign in to follow this