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; }
配置头文件和库目录
清理,重新生成,运行,测试。