C++ – How to include boost::thread in your C++ project

boostcmultithreading

What do I need to do to include boost::thread in my project? I have copied the whole thread folder to my working path (I wish to be able to run this on several computers) and I get

fatal error C1083: Cannot open include
file:
'boost/thread/detail/platform.hpp': No
such file or directory

From the line #include "thread/thread.hpp"

What gives?

edit:
Even if I just link to the boost folder where the precompiled binary installed and I use #include <boost/thread/thread.hpp> I get

fatal error LNK1104: cannot open file
'libboost_thread-vc90-mt-1_41.lib'

Best Answer

Unfortunately boost::thread is not a "header-only" library -- hence you need to have it compiled. There are basically two ways to go around it.

  1. you download a prebuilt install package from boostpro (assuming that you are on windows) -- https://sourceforge.net/projects/boost/files/boost-binaries/
  2. you can build it yourself - see http://www.boost.org/doc/libs/1_35_0/more/getting_started/index.html