第一步、建立項目
Visual C++-------win32控制台

預設選擇完成。
第二步、複制代碼
代碼如下:
#include <boost/lexical_cast.hpp> #include <iostream>
using namespace std;
}
return 0;
}
int main() { using boost::lexical_cast; int a = lexical_cast<int>("123"); double b = lexical_cast<double>("123.0123456789"); string s0 = lexical_cast<string>(a); string s1 = lexical_cast<string>(b); cout << "number: " << a << " " << b << endl; cout << "string: " << s0 << " " << s1 << endl; int c = 0; try{ c = lexical_cast<int>("abcd"); } catch (boost::bad_lexical_cast& e){ cout << e.what() << endl;
第三步、修改調試平台
因為編譯的靜态庫和動态連結是64位,選擇64位平台
第四步、設定編譯環境及連結
項目------選項----C/C++附加包含目錄----連結器附加庫目錄此項為頭檔案目錄,要保證能找到頭檔案,即C:\boost\boost_1_63_0中含有boost,而boost中為頭檔案。![]()
VS2017下boost配置第一步、建立項目第二步、複制代碼第三步、修改調試平台第四步、解決編譯時候産生的打不開檔案問題。第五步、調試運作結果如下圖所示,則配置完成。
此項為頭檔案目錄,要保證能找到頭檔案,即C:\boost\boost_1_63_0中含有boost,而boost檔案夾中為頭檔案。
點選連結器,附加庫目錄為編譯時候産生的包含靜态庫或動态連結的檔案夾,本文設定為編譯時候設定的C:\boost\bin1.63.0\VC14.0\lib。
如下圖所示:
将C:\boost\bin1.63.0\VC14.0\lib 粘貼進去,确定。
Note:如果編譯時候找不到,則重新設定本步驟。
第四步、解決編譯時候産生的打不開檔案問題。
便有錯誤如下:解決措施:(Win32): 已加載“C:\Windows\System32\ntdll.dll”。無法查找或打開 PDB 檔案。
點選調試-----選項-----右邊勾上“啟用源伺服器支援”----左邊點“符号”—右邊勾選“微軟符号伺服器”。
右邊勾上“啟用源伺服器支援”。
左邊點“符号”—右邊勾選“微軟符号伺服器”。
第五步、調試運作
使用Ctrl+f5
結果如下圖所示,則配置完成。
參考:
筆者的《VS2017下boost編譯》:http://blog.csdn.net/litingcheng1126/article/details/70333478
怎樣在VS2013中安裝配置boost_1_55_0庫:http://jingyan.baidu.com/article/11c17a2c765763f446e39dc1.html
VS2013環境下Boost庫配置:http://blog.csdn.net/fly_yr/article/details/48750413
VC包含目錄、附加依賴項、庫目錄及具體設定:http://www.cnblogs.com/MuyouSome/p/3380134.html
visual studio配置中包含目錄和附加包含目錄的差別以及auto-linking:http://blog.csdn.net/u012234115/article/details/54233095(分不清兩個庫配置可以讀讀,會有收獲。)
(Win32): 已加載“C:\Windows\System32\ntdll.dll”。無法查找或打開 PDB檔案:http://blog.csdn.net/sunnyliqian/article/details/50273987
VS2013 編譯程式時報無法加載PDB檔案錯誤解決方案:http://www.itnose.net/detail/6095821.html
boost / lexical_cast.hpp未找到:http://stackoverflow.com/questions/30687027/boost-lexical-cast-hpp-not-found