Since boost is a technology that uses templates, all of the code is written in a. hpp header file. In this way, most of the content in boost does not need to compile the corresponding link library, only need to set the following folder (or set the environment variable), in the source file including the corresponding header file can be used.
A few libraries need to generate a link library to use.
Here's how to install the Boost library in full:
1, first to the Boost website to download the latest version number of the Boost library:
http://www.boost.org/
2, unzip the file. From the command prompt, open to the root folder of the Boost library:
Double-click the Bootstrap.bat file, generate Bjam.exe, and run the following command:
Bjam--toolset=msvc--build-type=complete Stage
or simply double-click Bjam.exe.
Wait for the program to compile, about two hours or so. The Bin.v2 and stage two folders are generated under the Boost root folder. In the middle of the bin.v2 is the resulting intermediate file, about 2.7G in size, can be deleted directly. The DLL and LIB files are generated under stage.
3. Open vs:
View, property Manager, current project->debug| Win32->microsoft.cpp.win32.user Double-click
In the Properties dialog box that pops up:
Common Properties->vc++ folder: "Include folder": The root folder of boost. Example: D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0
Library folder: The link library folder under stage. Example: D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0\stage\lib
Generic properties, Linker, General: Additional library folders: Same as "library folder" above, example: D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0\stage\lib
So the environment is configured. Here's a test:
<span style= "FONT-SIZE:14PX;" ><pre name= "code" class= "CPP" ><span style= "Font-family:courier New;" > #include <cstdlib> #include <iostream> #include <vector> #include <iterator> #include < algorithm> #include <boost/timer.hpp> #include <boost/progress.hpp> #include <libs/date_time/src/ gregorian/greg_names.hpp> #include <libs/date_time/src/gregorian/date_generators.cpp> #include <libs/ Date_time/src/gregorian/greg_month.cpp> #include <libs/date_time/src/gregorian/gregorian_types.cpp># Include <boost/date_time/posix_time/posix_time.hpp>using namespace Boost;int main () {Boost::timer t;boost:: Progress_display PD (+); for (int i = 0; i <; ++i)//progress bar {++PD;} Boost::gregorian::d ate DT (2009, 12, 8); Date_time Library assert (dt.year () = =), assert (dt.day () = = 8); Boost::gregorian::d ate::ymd_type ymd = Dt.year_month_day ( );std::cout<< "\ n" <<ymd.year<< "/" <<ymd.month<< "/" <<ymd.day<< "The day was "<<dt.day_of_year () <<" Days of this year "<< std::endl;std::cout << Boost::gregorian:: to_iso_extended_string (DT) << Std::endl; Convert to other formats std::cout << boost::gregorian::to_iso_string (DT) << std::endl;std::cout << boost:: gregorian::to_simple_string (DT) << std::endl<<std::endl;//array sorting operations std::vector<int> TEST_VC (100); Std::vector<int>::iterator beg_it = Test_vc.begin (); Std::vector<int>::iterator end_it = Test_vc.end (); Std::srand (Std::time (NULL)); Std::for_each (Beg_it, End_it, [] (int& n) {n = rand ();}); Std::copy (Beg_it, End_it, std::ostream_iterator<int> (Std::cout, "")); std::cout << Std::endl << std: : Endl;std::sort (Beg_it, End_it, std::greater<int> ()); Std::copy (Beg_it, End_it, Std::ostream_iterator<int > (Std::cout, "")) std::cout << std::endl<<std::endl;boost::p osix_time::p Time Pt (Boost::gregorian:: Date (2005, 2, 6)) Std::cout << t.elapsed () << "s" << Std::endl; Program Execution Time System ("pause"); return 0;} </span></span>
The program executes correctly:
Author: http://blog.csdn.net/lp310018931
Basic usage of the Boost library under Windows