How to use Boost in Visual Studio 2010

后端 未结 13 1247
情歌与酒
情歌与酒 2020-11-22 07:14

What is a good step by step explanation on how to use the Boost library in an empty project in Visual Studio?

13条回答
  •  余生分开走
    2020-11-22 07:38

    I could recommend the following trick: Create a special boost.props file

    1. Open the property manager
    2. Right click on your project node, and select 'Add new project property sheet'.
    3. Select a location and name your property sheet (e.g. c:\mystuff\boost.props)
    4. Modify the additional Include and Lib folders to the search path.

    This procedure has the value that boost is included only in projects where you want to explicitly include it. When you have a new project that uses boost, do:

    1. Open the property manager.
    2. Right click on the project node, and select 'Add existing property sheet'.
    3. Select the boost property sheet.

    EDIT (following edit from @jim-fred):

    The resulting boost.props file looks something like this...

    
    
      
      
        D:\boost_1_53_0\
      
      
        $(BOOST_DIR);$(IncludePath)
        $(BOOST_DIR)stage\lib\;$(LibraryPath)
      
    
    

    It contains a user macro for the location of the boost directory (in this case, D:\boost_1_53_0) and two other parameters: IncludePath and LibraryPath. A statement #include would find thread.hpp in the appropriate directory (in this case, D:\boost_1_53_0\boost\thread.hpp). The 'stage\lib\' directory may change depending on the directory installed to.

    This boost.props file could be located in the D:\boost_1_53_0\ directory.

提交回复
热议问题