3

I want to include boost::unordered_map in my project without downloading the whole Boost package. How can I do that?

2 Answers 2

6

Use bcp: http://www.boost.org/doc/libs/1_52_0/tools/bcp/doc/html/index.html

cd $BOOST_DIR
bcp unordered_map /tmp/TEST

Now /tmp/TEST contains only the things required for unordered_map, in my case 15Mb (as opposed to 734Mb for the full boost library)

Sign up to request clarification or add additional context in comments.

Comments

0

You need at least headers because Boost packages depend on each other. You might want to select only needed header files but it will really be pain in the neck and will take you many hours. The algorithm is:

  1. Include only boost/unordered_map.
  2. While preprocessor complains about header that is not found:
    • Add that header.
    • Recompile.

You will end up with only necessary headers. But I can't see any advantages of this solution.

3 Comments

See my answer, no need for all the manual labour. Also, the fact that it takes only 2% of the size of the full library may very well be considered an advantage of this solution :)
Well, you, sir, just beat me. :) I had no idea such a tool exists.
Anyways, if you want to take the 'manual' approach (which makes sense to get the absolute minimum set of required headers) you'd do better to just run the source through the preprocessor and then something like egrep '^# [0-9]+ "' SpiritParser.i | cut -d'"' -f2 | sort -u | grep boost. No trial and error needed. Note that different compiler flags may result in different resulting header lists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.