WINDOWS-QT compiles c++boost using MinGW and uses

Source: Internet
Author: User

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 
  1. #include <iostream>
  2. #include <boost/math/special_functions/acosh.hpp>
  3. #include <boost/math/special_functions/bessel.hpp>
  4. #include <string>
  5. #include <boost/filesystem.hpp>
  6. #include <boost/timer.hpp>
  7. Using namespace Boost::math;
  8. Using namespace Boost::math::d etail;
  9. namespace fs = Boost::filesystem;
  10. Test boost Bessel function
  11. void Testbessel () {
  12. std::cout<<"Test Boost:" <<std::endl;
  13. Std::cout<<acosh (2.5) <<std::endl;
  14. Std::cout<<bessel_i0 (3.2) <<std::endl;
  15. std::cout<<"Test finished!"  <<std::endl;
  16. }
  17. Test boost File System library
  18. void Testfilesystem () {
  19. FS::p Ath Full_path ("C:");
  20. FS::d Irectory_iterator end_iter;
  21. For (fs::d irectory_iterator Dir_itr (full_path); Dir_itr! = End_iter; ++dir_itr)
  22. {
  23. Std::cout << Dir_itr->path (). FileName () << Std::endl;
  24. }
  25. }
  26. int main (int argc, char *argv[])
  27. {
  28. Std::cout << "-----test boost Bessel function-------" << Std::endl;
  29. Testbessel ();
  30. Std::cout << "-----Test boost File System library------" << Std::endl;
  31. Testfilesystem ();
  32. return 0;
  33. }

Added in Xxx_pro,

LIBS + =-lc:\qt\mingw\lib-lboost_system-lboost_filesystem

The performance is as follows,

[CPP]View PlainCopy 
  1. Starting D:\Documents\build-cplusplusboost-unknown-Debug\debug\cplusplusboost.exe ...
  2. -----Test the Boost Bessel function-------
  3. Test Boost:
  4. 1.5668
  5. 5.74721
  6. Test finished!
  7. -----Test the Boost File system library------
  8. "$RECYCLE. BIN "
  9. "Boost"
  10. "Boot"
  11. "Bootmgr"
  12. "Documents and Settings"
  13. "PerfLogs"
  14. "Program Files"
  15. "Program Files (x86)"
  16. "ProgramData"
  17. "Qt"
  18. "Recycler"
  19. "System Volume Information"
  20. "Users"
  21. "Windows"

http://blog.csdn.net/xiaopangzi313/article/details/52800799

WINDOWS-QT compiles c++boost using MinGW and uses

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.