下載安裝
進入官網下載地址:https://www.boost.org/users/download/
本教程直接下載官方已編譯庫,不涉及源代碼手動編譯

點擊官方編號好的鏈接,然后進入一個下載地址:https://sourceforge.net/projects/boost/files/boost-binaries/1.69.0/

下載完成后,安裝,本人的安裝路徑為:D:\WindowsSoftware\Boost1.67.0
創建一個項目測試代碼
1 #include <boost/lexical_cast.hpp>
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 using boost::lexical_cast;
9 int a = lexical_cast<int>("123");
10 double b = lexical_cast<double>("123.0123456789");
11 string s0 = lexical_cast<string>(a);
12 string s1 = lexical_cast<string>(b);
13 cout << "number: " << a << " " << b << endl;
14 cout << "string: " << s0 << " " << s1 << endl;
15 int c = 0;
16 try{
17 c = lexical_cast<int>("abcd");
18 }
19 catch (boost::bad_lexical_cast& e){
20 cout << e.what() << endl;
21 }
22
23 return 0;
24 }
設置編譯環境及鏈接
配置 >> C/C++ >> 常規 >> 附加包含目錄(此項為頭文件目錄,要保證能找到頭文件,即D:\WindowsSoftware\Boost1.67.0中含有boost,而boost文件夾中為頭文件)

點擊鏈接器,附加庫目錄為編譯時候產生的包含靜態庫或動態鏈接的文件夾,本文設置為編譯時候設置的D:\WindowsSoftware\Boost1.67.0\lib64-msvc-14.1

修改調試平台

解決編譯時候產生的打不開文件問題(可省略)
錯誤如:(Win32): 已加載“C:\Windows\System32\ntdll.dll”。無法查找或打開 PDB 文件。
解決措施:
點擊【調試】—【選項】— 右邊勾上“【啟用源服務器支持】”— 左邊點“【符號】”— 右邊勾選“【微軟符號服務器】”。


調試運行
CTRL+F5 直接運行
運行結果:

