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

What do I need to do to include boost :: thread in my project? I copied the entire stream folder to my work path (I want it to be able to run on multiple computers), and I get

Fatal error C1083: Cannot open 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 is installed and I use #include <boost/thread/thread.hpp> , I get

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

+5
c ++ multithreading boost
source share
4 answers

Unfortunately boost :: thread is not "header only", so you need to compile it. There are two ways around this.

+11
source share

After you download, unzip and install boost libraries in Visual Studio and talk about the Visual Studio project that Boost libraries live in, you are not quite finished yet. There are several libraries in Boost libraries that require you to create them yourself. Boost threads is one such library.

  • Create the bjam.exe program if you have not already done so. Probably the easiest way is to get and run it directly from BoostPro , specifying the installation, which of the libraries (streams) you want to install - you do not need to install all of them.

  • Go to the directory C: \ Program Files \ boost_1_46_1 \ tools \ build \ v2 \ engine \ src and run build.bat from the command line. Running build.bat script will create bjam.exe inside this directory: C: \ Program Files \ boost_1_46_1 \ tools \ build \ v2 \ engine \ src \ bin.ntx86

  • Select bjam.exe in your PATH environment variables. Include the C: \ Program Files \ boost_1_46_1 \ tools \ build \ v2 \ engine \ src \ bin.ntx86 directory as another environment variable.

  • At the command prompt, change to the directory C: \ Program Files \ boost_1_46_1, enter "bjam", waiting about 5-10 minutes when creating the program.

  • In a Visual Studio project, select Configuration Properties → Linker → Input → Additional Dependencies and type libboost_thread-vc100-mt-gd-1_46_1.lib.

  • In the Visual Studio project, set the project configuration properties → Linker → General → Include Additional Directories by specifying the location of the stage / lib folder, for example C: \ Program Files \ Boost_1_46_1 \ stage \ lib.

That should be enough to make you move. See this blog for more details.

+2
source share

I was getting a compile time error for 'boost :: thread'. But it is allowed when I included the following header.

 #include <boost\thread.hpp> 
0
source share

Fatal error C1083 is a Visual C ++ error. You must include the library folder from boost in your project. "C: \ Program Files \ boost \ boost_1_41 \ lib" if you are using boostpro.

Also, when you download a stream library using boostpro, you need to check it in the list (you can also choose a compiler ...).

-one
source share

All Articles