I want to include boost::unordered_map in my project without downloading the whole Boost package. How can I do that?
2 Answers
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)
Comments
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:
- Include only
boost/unordered_map. - 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
sehe
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 :)
Archie
Well, you, sir, just beat me. :) I had no idea such a tool exists.
sehe
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.