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'
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.
Once you have downloaded, unzipped and installed the boost libraries in your Visual Studio environment, and told the Visual Studio project where the Boost libraries live, you are not quite finished yet. There exist a number of libraries in Boost libraries that require that you build them yourself. Boost threads is one such library.
Build the bjam.exe program if you have not already done it. Probably the simplest way to is to get and run it direct from BoostPro, telling the installation which of the libraries (threads) you wish to install – you don't have to install all of them.
Go to the C:\Program Files\boost_1_46_1\tools\build\v2\engine\src directory and run build.bat from the command prompt. Running the 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 the bjam.exe into in your PATH environment variables. Include the directory C:\Program Files\boost_1_46_1\tools\build\v2\engine\src\bin.ntx86 as another environment variable.
At the command prompt, go to the C:\Program Files\boost_1_46_1 directory, enter “bjam”, waiting for approximately 5-10 minutes while the program gets created.
In your Visual Studio project select Configuration Properties -> Linker -> Input -> Additional Dependencies and enter libboost_thread-vc100-mt-gd-1_46_1.lib.
In your Visual Studio project set the project configuration properties -> Linker -> General -> Additional Include Directories, telling it the location of the stage/lib folder eg C:\Program Files\Boost_1_46_1\stage\lib.
That should be sufficient to get you going. For more comprehensive details, please see this blog posting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With