如何Visual Studio环境使用 C++ Boost库,详细步骤
How to build the Boost Library
(refer to the link: http://www.boost.org/doc/libs/1_60_0/more/getting_started/windows.html#header-only-libraries)
1. download the BOOST Lib from GitHub: https://github.com/boost-cmake/boost
2. Unzip the downloaded file to a local folder, the rootfolder is boost-master
3. Open the command prompt window and change the current directoryto the Boost root directory.
4. Type the command: bootstrap.bat and then enter
If you encounted an error:
“Building Boost.Build engine
'cl' is not recognized as an internal or external command,operable program or batch file.”
Please make sure execute the command in the compiler commandline prompt.
5. Type the command: .\b2 and then enter
6. After the two commands are completed successfully, a newfolder boost-master/boost created.
7. BuildFrom the Visual Studio IDE (here I use VS2015)
· From Visual Studio's File menu,select New > Project…
· In the left-hand pane of the resulting NewProject dialog, select Visual C++ > Win32.
· In the right-hand pane, select Win32Console Application (VS8.0) or Win32 Console Project (VS7.1).
· In the name field, enter“example”
· Right-click example inthe Solution Explorer pane and select Properties fromthe resulting pop-up menu
· In Configuration Properties > C/C++ > General > AdditionalInclude Directories, enter the path to the Boost root directory, forexample
C:\Program Files\boost\boost_1_60_0
· In Configuration Properties > C/C++ > PrecompiledHeaders, change Use Precompiled Header (/Yu) to NotUsing Precompiled Headers.2
· Replace the contents of the example.cpp generatedby the IDE with the example code above.
#include<boost/lambda/lambda.hpp>
#include<iostream>
#include<iterator>
#include<algorithm>
intmain()
{
using namespace boost::lambda;
typedef std::istream_iterator<int>in;
std::for_each(
in(std::cin), in(), std::cout <<(_1 * 3) << " " );
}
· From the Build menu,select Build Solution.
8. To test your application, hit the F5 key and type the followinginto the resulting window, followed by the Return key:
1 2 3
Thenhold down the control key and press "Z", followed by the Return key.
上一篇: C语言(Visual Studio)
下一篇: mybatis的基本了解