# How to compile boost?

This topic is 3096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
Quote:
 Original post by WindScarIs 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 on other sites
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 on other sites
Quote:
 Original post by owlboost 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 on other sites
Quote:
 Original post by snk_kidFurthermore 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 on other sites
Quote:
Original post by BitMaster
Quote:
 Original post by snk_kidFurthermore 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 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 on other sites
Quote:
Original post by snk_kid
Quote:
 Original post by owlboost 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.

• 11
• 19
• 12
• 34
• 9
• ### Forum Statistics

• Total Topics
631398
• Total Posts
2999838
×