1. 下載boost, 解壓,進入boost源目錄
2. 打開vs2017 x86 CMD工具,輸入bootstrap.bat,等待初始化完畢
x86編譯
bjam stage --toolset=msvc-14.1 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_69_0\bin\vc141-x86" link=static runtime-link=shared runtime-link=static threading=multi debug release
3. VS2017
創建測試項目
// TestBoost.cpp : 此文件包含 "main" 函數。程序執行將在此處開始並結束。 // #include "pch.h" #include <boost/lexical_cast.hpp> #include <boost/regex.hpp> #include <iostream> using namespace std; 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; } return 0; }
配置頭文件和庫目錄
清理,重新生成,運行,測試。