windows系統VS2017編譯boost


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;
}

配置頭文件和庫目錄

image

清理,重新生成,運行,測試。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM