How to use Boost in Visual Studio 2010

后端 未结 13 1242
情歌与酒
情歌与酒 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:30

    While the instructions on the Boost web site are helpful, here is a condensed version that also builds x64 libraries.

    • You only need to do this if you are using one of the libraries mentioned in section 3 of the instructions page. (E.g., to use Boost.Filesystem requires compilation.) If you are not using any of those, just unzip and go.

    Build the 32-bit libraries

    This installs the Boost header files under C:\Boost\include\boost-(version), and the 32-bit libraries under C:\Boost\lib\i386. Note that the default location for the libraries is C:\Boost\lib but you’ll want to put them under an i386 directory if you plan to build for multiple architectures.

    1. Unzip Boost into a new directory.
    2. Start a 32-bit MSVC command prompt and change to the directory where Boost was unzipped.
    3. Run: bootstrap
    4. Run: b2 toolset=msvc-12.0 --build-type=complete --libdir=C:\Boost\lib\i386 install

      • For Visual Studio 2012, use toolset=msvc-11.0
      • For Visual Studio 2010, use toolset=msvc-10.0
      • For Visual Studio 2017, use toolset=msvc-14.1
    5. Add C:\Boost\include\boost-(version) to your include path.

    6. Add C:\Boost\lib\i386 to your libs path.

    Build the 64-bit libraries

    This installs the Boost header files under C:\Boost\include\boost-(version), and the 64-bit libraries under C:\Boost\lib\x64. Note that the default location for the libraries is C:\Boost\lib but you’ll want to put them under an x64 directory if you plan to build for multiple architectures.

    1. Unzip Boost into a new directory.
    2. Start a 64-bit MSVC command prompt and change to the directory where Boost was unzipped.
    3. Run: bootstrap
    4. Run: b2 toolset=msvc-12.0 --build-type=complete --libdir=C:\Boost\lib\x64 architecture=x86 address-model=64 install
      • For Visual Studio 2012, use toolset=msvc-11.0
      • For Visual Studio 2010, use toolset=msvc-10.0
    5. Add C:\Boost\include\boost-(version) to your include path.
    6. Add C:\Boost\lib\x64 to your libs path.

提交回复
热议问题