Boost Consultancy has created a wizard based installer for downloading and installing the correct version of Boost components on a Windows machine for Visual Studio .NET IDEs. The Installer simplifies the process of installation by getting rid of the time-consuming, and on rare occasions error-prone, process of compilation from the sources. But if you use any IDE other than Visual Studio .NET(even the old Visual Studio 6.0 IDE) then you need to use the typical Boost installation method(). Below is the procedure to install Boost for Visual Studio .NET IDEs using the Boost Installer for Windows.
- Download Boost Installer for Windows(~180K in size) from Boost Consultancy website. Run the installer. You will see the following license agreement displayed(Installer license).

Read it and press "I Agree" if you agree to the terms. Another license agreement will be displayed next(Boost Libraries license).

Read it too and press "I Agree" again if you agree to the terms.
- Based on your geographical location, you can select one of the nearest location from the provided list of mirror locations. Select one or leave the default selection to select a location randomly. Press "Next".
- The following dialog box allows one or more variants of Boost libraries to be selected for downloading and installing on your system. First select the complier to download Boost libraries for. If you have both Visual Studio .NET 2003 and 2005 versions installed, and so prefer to use Boost with both of them, then you can select both the compilers in the left pane("Compilers").
Then select which variant(s) of Boost library binaries you want to install. If you have absolutely no idea what to select here, then go with "Multithread Debug, static runtime" among any others you want to select. Press "Next" after making your selection(s).
- The next dialog box prompts the user to select the components of Boost to be installed. You may consider including "Source and Documentation" if the download size is not a big concern for you. The same (but updated) documentation is always available at Boost Documentation page anyway.
- I prefer to select a destination folder path that doesn't contain any spaces or special characters in it. Accept the default path as shown below to use Boost with Microsoft products or get into the habit of always installing programming or Unix like tools in paths that don't contain any spaces in them, like: C:/boost/boost_1_34_1 or C:/programs/boost/boost_1_34_1. (MinGW, Eclipse etc will be very happy with paths like these.)
- Time to take a coffee break. Depending upon the download size and the speed of the Internet connection, the download and install process may take some time to finish. (To give you an idea, it downloaded ~90MB in around 30 minutes of time on my machine.)
- Installation is finished.

Time to start testing the installation.
Testing Boost Installation in Visual Studio .NET 2003/2005/Orcas
Boost has two type of libraries : header-only(which are compiler independent) and compiled binary libraries.
- Testing Boost Header-only libraries:
- Start the Microsoft Visual Studio .NET IDE and create a new C++ project in it(File -> New Project). select Visual C++ -> Win32 in the left pane and Win32 Console Application/Win32 Console Project in the right pane. Enter a name(BoostDemo) for the project and click OK.
- Right-click on the project name and select Properties(or select Project->BoostDemo Properties). Select Configuration Properties -> C/C++ -> General in the left pane and type/select Boost installation root directory(C:/boost/boost_1_34_1) in "Additional Include Directories" field in the right pane.
- Add the following code just above the _tmain() function(in the generated file - BoostDemo.cpp).
C++:
-
#include<iostream>
-
#include<boost/any.hpp>
Add the following code with in the _tmain() function:
C++:-
boost:: any a ( 5 );
-
a = 7. 67;
-
std:: cout<< boost:: any_cast<double> (a )<<std:: endl;
-
- Select Build -> Build Solution to build the project and, assuming the build completes successfully without any errors, select Debug->Start Debugging to run the program.
- Start the Microsoft Visual Studio .NET IDE and create a new C++ project in it(File -> New Project). select Visual C++ -> Win32 in the left pane and Win32 Console Application/Win32 Console Project in the right pane. Enter a name(BoostDemo) for the project and click OK.
- Testing Boost Compiled Binary Libraries
- First complete the Header-only test as described above. In the same project, right-click on the project name and select "Properties". Select Configuration Properties -> Linker in the left pane and type/select the Boost lib directory path(C:/boost/boost_1_34_1/lib) in "Additional Library Directories" field in the right pane.
- Add the following code just above the _tmain() function
C++:
-
#include<boost/filesystem/operations.hpp>
-
namespace bfs= boost:: filesystem;
Add the following code with in the _tmain() function:
C++:-
bfs:: path p ( "BoostDemo.cpp" );
-
if (bfs:: exists (p ) )
-
std:: cout<<p. leaf ( )<<std:: endl;
-
- Build and run the program as before.
- First complete the Header-only test as described above. In the same project, right-click on the project name and select "Properties". Select Configuration Properties -> Linker in the left pane and type/select the Boost lib directory path(C:/boost/boost_1_34_1/lib) in "Additional Library Directories" field in the right pane.
I have tested the above procedure with the latest release of Visual Studio Orcas Beta too.
A NOTE:
-
#define BOOST_ALL_DYN_LINK
-
#define BOOST_LIB_DIAGNOSTIC
Also you need to add the path to the dlls(C:/boost/boost_1_34_1/lib) to the system PATH variable(Control Panel -> System -> Advanced System Settings -> Environment Variables) before running the programs. This has to be done only once.
本文提供了一个详细的步骤指南,教你如何使用BoostConsultancy提供的安装向导在Windows环境下为VisualStudio.NET安装正确的Boost组件版本。该过程简化了从源代码编译的时间消耗,并避免了可能的错误。文中还包含了如何测试安装是否成功的示例代码。
2861

被折叠的 条评论
为什么被折叠?



