C++ 调用boost步骤:
第一步、配置boost
While Nate's answer is pretty good already, I'm going to expand on it more specifically for Visual Studio 2010 as requested, and include information on compiling in the various optional components which requires external libraries.
If you are using headers only libraries, then all you need to do is to unarchive the boost download and set up the environment variables. The instruction below set the environment variables for Visual Studio only, and not across the system as a whole. Note you only have to do it once.
Unarchive the latest version of boost (1.47.0 as of writing) into a directory of your choice (e.g.C:\boost_1_47_0).
Create a new empty project in Visual Studio.
Open the Property Manager and expand one of the configuration for the platform of your choice.
Select & right click Microsoft.Cpp.
Select VC++ Directories on the left.
Edit the Include Directories section to include the path to your boost source files.
Repeat steps 3 - 6 for different platform of your choice if needed.
If you want to use the part of boost that require building, but none of the features that requires external dependencies, then building it is fairly simple.
Unarchive the latest version of boost (1.47.0 as of writing) into a directory of your choice (e.g.C:\boost_1_47_0).
Start the Visual Studio Command Prompt for the platform of your choice and navigate to where boost is.
Run: bootstrap.bat to build b2.exe (previously named bjam).
Run b2: (Win32) b2 --toolset=msvc-10.0 --build-type=complete stage ; (x64) b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage. Go for a walk / watch a movie or 2 / ....
Go through steps 2 - 6 from the set of instruction above to set the environment variables.
Edit the Library Directories section to include the path to your boost libraries output. (The default for the example and instructions above would be C:\boost_1_47_0\stage\lib. Rename and move the directory first if you want to have x86 & x64 side by side (such as to
Repeat steps 2 - 6 for different platform of your choice if needed.
If you want the optional components, then you have more work to do. These are:
Boost.IOStreams Bzip2 filters
Boost.IOStreams Zlib filters
Boost.MPI
Boost.Python
Boost.Regex ICU support
Boost.IOStreams Bzip2 filters:
Unarchive the latest version of bzip2 library (1.0.6 as of writing) source files into a directory of your choice (e.g. C:\bzip2-1.0.6).
Follow the second set of instructions above to build boost, but add in the option -sBZIP2_SOURCE="C:\bzip2-1.0.6" when running b2 in step 5.
Boost.IOStreams Zlib filters
Unarchive the latest version of zlib library (1.2.5 as of writing) source files into a directory of your choice (e.g. C:\zlib-1.2.5).
Follow the second set of instructions above to build boost, but add in the option -sZLIB_SOURCE="C:\zlib-1.2.5" when running b2 in step 5.
Boost.MPI
Install a MPI distribution such as Microsoft Compute Cluster Pack.
Follow steps 1 - 3 from the second set of instructions above to build boost.
Edit the file project-config.jam in the directory
Follow the rest of the steps from the second set of instructions above to build boost. If auto-detection of the MPI installation fail, then you'll need to look for and modify the appropriate build file to look for MPI in the right place.
Boost.Python
Install a Python dis