7

I've been playing around with some Boost components, and the only one I see a direct need for in the project I'm working on is boost::shared_ptr.

Would it be difficult to just include the required files for shared_ptr, or at least just include files for the Boost smart_ptr directory in my project? They seem to have some external dependencies on other parts of Boost - but I figure there's an easy way to just use certain components of the Boost library and I'm missing it.

If you can tell me what parts I need or point me to a good tutorial I'd be most grateful!

Praetorian
  • 106,671
  • 19
  • 240
  • 328
John Humphreys
  • 37,047
  • 37
  • 155
  • 255

2 Answers2

10

You can use the bcp tool to extract only the header you want.

bcp shared_ptr /foo

This copies shared_ptr and all dependencies to the directory foo

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Praetorian
  • 106,671
  • 19
  • 240
  • 328
-3

You can only include the shared_ptr headers from boost like this

#include <boost/shared_ptr.hpp>

look at a basic example here or for more examples here

you can include nearly every part of the boost lib in this way and it has nearly no further dependencies (only for some more complex libs)

ben
  • 1,819
  • 15
  • 25
  • Well, bcp page says it would find 274 header dependencies for `boost/shared_ptr.hpp` - most not needed for one compiler with one configuration. I don't think it is that easy to extract libraries from boost (it sounds like OP wants to keep shared_ptr and throw away the rest). – UncleBens Oct 07 '11 at 22:32
  • @UncleBens Yeah, that's what I was preferably looking to do - I appreciate the suggestion though! :) – John Humphreys Oct 07 '11 at 22:36
  • You're misunderstanding the question, which is not "How do I use #include on boost files" but "How do I determine which boost files I need to distribute for #include to work?" – Tom Swirly Apr 11 '13 at 21:15