First, boost is a quasi-standard library, equivalent to the continuation and expansion of the STL, its design concept and STL is closer, are to use generics to maximize reuse. But comparing stl,boost is more practical. The STL is concentrated in the algorithm part, and the boost contains a lot of tool classes, can do more specific work. Given the power of boost, this has been done specifically for Windows Migration compilation operations.
Second, the boost of the transplant
1. Download Boost Source boost_1_62_0.7z,:https://sourceforge.net/projects/boost/
In fact, you can also download boos compiled library and header files, but for unnecessary trouble, it is recommended to manually compile
2. Compile boost
1) Extract boost to D drive, directory is boost_1_62
2) Generate Bjam tool:
Enter the D:\boost_1_62_0\boost_1_62_0\tools\build\src\engine directory, execute build.sh GCC, in the current directory will generate Bin.ntx86 folder, which contains two EXE files B2.exe , Bjam.exe
3) Copy Bin.ntx86\bjam.exe to boost1.37 's extract directory D:\boost_1_62_0\boost_1_62_0
4) Enter the path D:\boost_1_62_0\boost_1_62_0, execute Bjam "TOOLSET=GCC" Install, wait for a period of time, will generate a boost folder in the C packing directory, It contains the generated header file and Lib and DLL text.
5) Copy the Boost folder under the C:\Boost\include\boost-1_37 directory to the C:\MinGW\include below
6) Copy the Lib file under C:\Boost\lib to C:\MinGW\lib and copy the DLL file under C:\Boost\lib to the C:\MinGW\bin
Third, the use of boost
Program code into the following:
[CPP]View PlainCopy
- #include <iostream>
- #include <boost/math/special_functions/acosh.hpp>
- #include <boost/math/special_functions/bessel.hpp>
- #include <string>
- #include <boost/filesystem.hpp>
- #include <boost/timer.hpp>
- Using namespace Boost::math;
- Using namespace Boost::math::d etail;
- namespace fs = Boost::filesystem;
- Test boost Bessel function
- void Testbessel () {
- std::cout<<"Test Boost:" <<std::endl;
- Std::cout<<acosh (2.5) <<std::endl;
- Std::cout<<bessel_i0 (3.2) <<std::endl;
- std::cout<<"Test finished!" <<std::endl;
- }
- Test boost File System library
- void Testfilesystem () {
- FS::p Ath Full_path ("C:");
- FS::d Irectory_iterator end_iter;
- For (fs::d irectory_iterator Dir_itr (full_path); Dir_itr! = End_iter; ++dir_itr)
- {
- Std::cout << Dir_itr->path (). FileName () << Std::endl;
- }
- }
- int main (int argc, char *argv[])
- {
- Std::cout << "-----test boost Bessel function-------" << Std::endl;
- Testbessel ();
- Std::cout << "-----Test boost File System library------" << Std::endl;
- Testfilesystem ();
- return 0;
- }
Added in Xxx_pro,
LIBS + =-lc:\qt\mingw\lib-lboost_system-lboost_filesystem
The performance is as follows,
[CPP]View PlainCopy
- Starting D:\Documents\build-cplusplusboost-unknown-Debug\debug\cplusplusboost.exe ...
- -----Test the Boost Bessel function-------
- Test Boost:
- 1.5668
- 5.74721
- Test finished!
- -----Test the Boost File system library------
- "$RECYCLE. BIN "
- "Boost"
- "Boot"
- "Bootmgr"
- "Documents and Settings"
- "PerfLogs"
- "Program Files"
- "Program Files (x86)"
- "ProgramData"
- "Qt"
- "Recycler"
- "System Volume Information"
- "Users"
- "Windows"
http://blog.csdn.net/xiaopangzi313/article/details/52800799
WINDOWS-QT compiles c++boost using MinGW and uses