Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you deal with large dependencies in Boost?

Boost is a very large library with many inter-dependencies -- which also takes a long time to compile (which for me slows down our CruiseControl response time).

The only parts of boost I use are boost::regex and boost::format.

Is there an easy way to extract only the parts of boost necessary for a particular boost sub-library to make compilations faster?

EDIT: To answer the question about why we're re-building boost...

  1. Parsing the boost header files still takes a long time. I suspect if we could extract only what we need, parsing would happen faster too.
  2. Our CruiseControl setup builds everything from scratch. This also makes it easier if we update the version of boost we're using. But I will investigate to see if we can change our build process to see if our build machine can build boost when changes occur and commit those changes to SVN. (My company has a policy that everything that goes out the door must be built on the "build machine".)
like image 267
Kevin Avatar asked Oct 06 '08 06:10

Kevin


People also ask

Why is Boost so large?

Since Boost is a bunch of templates, it causes a bunch of member functions to be compiled per type used. If you use boost with n types, the member functions are defined (by C++ templates) n times, one for each type.

How do you contribute to Boost?

To participate in development, you need to subscribe to the Boost developers' list. Once you've done that, some paths to contribution are: Submit patches for new features or bug fixes. Pick any ticket from our bug tracking system on GitHub and get started.

What do the Boost libraries do?

Boost is a set of libraries for the C++ programming language that provides support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing.


3 Answers

First, you can use the bcp tool (can be found in the tools subfolder) to extract the headers and files you are using. This won't help with compile times, though. Second, you don't have to rebuild Boost every time. Just pre-build the lib files once and at every version change, and copy the "stage" folder at build time.

like image 105
vividos Avatar answered Oct 23 '22 10:10

vividos


Unless you are patching the boost libraries themselves, there is no reason to recompile it every time you do a build.

like image 44
postfuturist Avatar answered Oct 23 '22 08:10

postfuturist


We're using Boost, but we only include object files for those types that we actually use. I.e., we build our own static library with a bunch of home-grown utilities and include those parts of Boost that we find useful. Our CMakeLists.txt looks something like this (you should be able to load this in CMake, if you adjust SOURCES accordingly.)

project( MyBoost )

set(SOURCES 
  boost/regex/src/c_regex_traits.cpp
  boost/regex/src/cpp_regex_traits.cpp
  boost/regex/src/cregex.cpp
  boost/regex/src/fileiter.cpp
  boost/regex/src/icu.cpp
  boost/regex/src/instances.cpp
  boost/regex/src/posix_api.cpp
  boost/regex/src/regex.cpp
  boost/regex/src/regex_debug.cpp
  boost/regex/src/regex_raw_buffer.cpp
  boost/regex/src/regex_traits_defaults.cpp
  boost/regex/src/static_mutex.cpp
  boost/regex/src/usinstances.cpp
  boost/regex/src/w32_regex_traits.cpp
  boost/regex/src/wc_regex_traits.cpp
  boost/regex/src/wide_posix_api.cpp
  boost/regex/src/winstances.cpp
)

add_library( MyBoost STATIC ${SOURCES})
like image 2
JesperE Avatar answered Oct 23 '22 08:10

JesperE