編譯並使用boost庫(boost1.63+vs2015+32位or 64位),超詳細,boost於vs2017下編譯(64/32bit)

首先下載得到boost的最新版(目前最新版是1.63)

下載地址:
 

也可以從這裏直接下載

http://download.csdn.net/detail/zengraoli/9815337

下載完成後解壓出來


編譯32位的boost庫

 

打開vs的32位命令行工具

 

進入到boost源代碼文件夾中

 

進入到boost源代碼文件夾中

 

運行bootstrap.bat

 

執行如下操作,對boost進行編譯

(msvc版本14.0對應的是vs2015,--stagedir是指定編譯後存放的目錄,文章附錄有vs版本對應編號)

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

 

這樣得到的是就是32位的boot庫


編譯64位的boost庫

打開vs的64位命令行工具

 
 

進入到boost源代碼文件夾中

 

運行bootstrap.bat

 

執行如下操作,對boost進行編譯

(msvc版本14.0對應的是vs2015,--stagedir是指定編譯後存放的目錄)

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


這樣得到的是就是64位的boot庫

開始使用boost

 

設置測試的程序爲64位

 

設置附加的包含路徑(下載之後解壓的boost文件夾):

 

設定庫路徑:

 
 

然後建立第一個boost項目,代碼如下:

  1.  
    #include "boost/thread.hpp"
  •  
    #include "iostream"
  •  
    using namespace std;
  •  
     
  •  
    void mythread()
  •  
    {
  •  
    cout << " hello,thread! " << endl;
  •  
    }
  •  
     
  •  
    int _tmain(int argc, _TCHAR* argv[])
  •  
    {
  •  
    boost::function<void()> f(mythread);
  •  
    boost::thread t(f);
  •  
    t.join();
  •  
    cout << " thread is over! " << endl;
  •  
     
  •  
     
  •  
    return 0;
  •  
    }
  • 得到輸出
     

    附錄

    附上版本對應編號

    1.  
      VC6
  •  
    VC7(2003)
  •  
    VC8(2005)
  •  
    VC9(2008)
  •  
    VC10(2010)
  •  
    VC11(2012)
  •  
    VC12(2013)
  •  
     

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

    一個boost線程池的例子

    附帶一個boost使用線程池的例子

    http://blog.csdn.net/zengraoli/article/details/70187693

     
     
     
    下面文章是vs2015編譯, 將140換爲141,則可以編譯給vs2017用.
    編譯64位:
    先打開vs2017 64位環境的cmd環境, 進入boost源目錄, 運行bootstrap.bat,然後運行下面編譯命令,
    stagedir用來指定庫存放的位置
    bjam stage --toolset=msvc-14.1 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="c:\boost\boost_1_64_0\bin\vc141-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release
    編譯32位:
    先打開vs2017 x86環境的cmd環境, 進入boost源目錄, 運行bootstrap.bat,然後運行下面編譯命令,
    bjam stage --toolset=msvc-14.1 --without-graph --without-graph_parallel --stagedir="c:\boost\boost_1_64_0\bin\vc141-x86" link=static runtime-link=shared runtime-link=static threading=multi debug release
    要等好一會兒的.
     
    https://blog.csdn.net/rocklee/article/details/72885587
    發表評論
    所有評論
    還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
    相關文章