1. Download the latest boost library: http://www.boost.org/users/download/
2. Unzip the file to a certain folder, which would be used later as a path in the user configuration in Visual Studio 2010. Here I'll use "D:\boost_1_50_0\" for example.
3. A large part of the library is only header file, need not to be compiled. To get a full version(due to the "geek's nature"), we need to compile the library.
Click "Start"->"All programs"->"Microsoft Visual Studio 2010"->"Visual Studio Tools"->"Visual Studio Command Prompt (2010)"
This command window has correct environment configuration for VS2010. Now go to the place where you unzip the boost library using "cd" command. Here the location is "D:\boost_1_50_0\", so the command is "cd D:\boost_1_50_0\".
4. Run command "bootstrap". Running this could give you a executable called "bjam", which is the building system for boost.
5. Run command:
bjam toolset=msvc-10.0 variant=debug,release threading=multi link=static
The parameters setting may vary depending on user's own interest.
Notice that the compiling process may take more than 20 minutes. So take the time to do something else.
6. Now we've finished compiling the library, and it's time to turn to setting Visual Studio. Go to "C:\Users\%USERNAME\AppData\Local\Microsoft\MSBuild\v4.0"
Open the Microsoft.Cpp.Win32.user.props file and modify it.
Under the <IncludePath> tag add the root folder where you extract the boost library. Here is "D:\boost_1_50_0;"
Unver the <LibraryPath> tag do a similar thing, but with different path, under the folder "/stage/lib". Here is "D:\boost_1_50_0\stage\lib;"
In this way you don't have to configure your every project to support boost. As long as you're logging in as this certain user, the boost library would always be found without costing your time to set project property.
Try to some example code from boost document!
Create an empty win32 console project and add these lines of code to the main.cpp and see the result.
#include <boost/regex.hpp> #include <iostream> #include <string> int main() { std::string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); while (std::cin) { std::getline(std::cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) std::cout << matches[2] << std::endl; } }
I followed this video tutorial:
Big thanks to the author and hope everyone could benefit from that.
Thanks
ReplyDelete