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

前端 未结 4 2039
长发绾君心
长发绾君心 2020-12-19 07:38

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) a

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 08:32

    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.

    1. 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.

    2. 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

    3. 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.

    4. 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.

    5. In your Visual Studio project select Configuration Properties -> Linker -> Input -> Additional Dependencies and enter libboost_thread-vc100-mt-gd-1_46_1.lib.

    6. 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.

提交回复
热议问题