Boost library installation and compilation under window7 + visual studio 2015

I want to use the boost library under windows vs 2015. The installation under windows is not as easy as ubuntu. I saw a blog post that perfectly compiled the 32-bit and 64-bit boost libraries. transfer

Original: https://blog.csdn.net/zengraoli/article/details/70187556

First download the latest version of boost (currently the latest version is 1.63)


download link:


After downloading, unzip it


Compile 32-bit boost library

Open 32-bit command line tools for vs



Go to the boost source code folder



Go to the boost source code folder



run bootstrap.bat



Do the following to compile boost

( msvc version 14.0 corresponds to vs2015 , --stagedir is the specified directory after compilation, and the article appendix has the corresponding number of the vs version)

[cpp]  view plain copy  
  1. bjam stage --toolset=msvc-14.0 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14" link=static runtime-link=shared runtime-link=static threading=multi debug release  



This is the 32-bit boot library


Compile 64-bit boost library

Open 64-bit command line tools for vs



Go to the boost source code folder



run bootstrap.bat



Do the following to compile boost

( msvc version 14.0 corresponds to vs2015 , --stagedir is the directory where it is stored after compilation)

[cpp]  view plain copy  
  1. bjam stage --toolset=msvc-14.0 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release  


This is the 64-bit boot library

get started with boost

Set the test program to 64-bit



Set additional include paths (boost folder unzipped after download):



Set the library path:




Then build the first boost project with the following code:

[cpp]  view plain copy  
  1. #include "boost/thread.hpp"  
  2. #include "iostream"  
  3. usingnamespace std;   
  4.   
  5. void mythread()  
  6. {  
  7.     cout << " hello,thread! " << endl;  
  8. }  
  9.   
  10. int _tmain(int argc, _TCHAR* argv[])  
  11. {  
  12.     boost::function<void()> f(mythread);  
  13.     boost::thread t(f);  
  14.     t.join();  
  15.     cout << " thread is over! " << endl;  
  16.   
  17.   
  18.     return 0;  
  19. }  

get the output

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326126711&siteId=291194637