tags:

views:

128

answers:

4

is there a way to use boost's threading capabilities without the entire boost library? What are the bare minimum h and cpp files needed for this?

Thanks

A: 

http://www.boost.org/doc/libs/1_43_0/doc/html/thread.html

According to the above you need at least

#include <boost/thread.hpp>

Kyle
This pulls in lots of other headers throughout boost though
the_mandrill
@madrill -- most of boost is header only, and many parts are templates or macros that have no impact on object file size as long as you don't use them. Even if you do pull in more, the linker will discard pieces you don't use when creating an executable (assuming you are doing static linking, which as far as I can tell is typical with boost).
John Gaughan
@John - yes, I appreciate that, but the OP ask for the bare minimum of .h and .cpp files required. Besides, the thread library is one of the ones that must be built.
the_mandrill
@mandrill -- I realize that the macros/templates are a moot point since the compiler creates them as needed, but regardless, the linker should exclude objects it does not need. While that may not answer the question, it does partially address the issue. Essentially, compiling the thread part of the library and linking against it will only include the parts that are absolutely required for boost::threads.
John Gaughan
+9  A: 

You need to use the boost bcp tool which will copy only the parts of boost which are required for any of the libraries of your choice.

the_mandrill
404 file not found.
John Gaughan
@John: Idan K fixed the link :)
Matthieu M.
Thanks -- the boost site was quite unresponsive yesterday so it was difficult to tell whether the link was correct.
the_mandrill
It's ok -- from what I could tell, half the internet was unresponsive yesterday. Maybe it was just my cable co, but I figured when the boost site did respond with a 404 I'd help out. The link works now, thanks.
John Gaughan
A: 

Soon you will have std::thread as a standardized version

http://www2.research.att.com/~bs/C++0xFAQ.html#std-thread

If you have access to C++0x, your favorite compiler may already have some of these things implemented like gcc 4.5+

David
+1  A: 

There's actually a small library that was created for just this purpose: TinyThread++

It gives you (sort of) a subset of the upcoming C++0x standard threading API, in just one .h file and one .cpp file (no complicated build, no dependencies). And, it's very portable (and open source, of course).

Hope it helps...

marcus256