How to compile boost?

Started by
8 comments, last by owl 14 years, 3 months ago
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.
Please point my english mistakes everytime you can.
Advertisement
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]
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.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

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.
<a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=524542>linking to *.lib with MinGW/g++. It worked when I renamed them to *.a. I think it was just a bug in the build system's output names, which may have been fixed.
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.
[size="2"]I like the Walrus best.
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]
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.
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.
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. ;)
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.
[size="2"]I like the Walrus best.

This topic is closed to new replies.

Advertisement