欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VS2022配置編譯使用boost庫(kù)的實(shí)現(xiàn)

 更新時(shí)間:2024年12月02日 11:56:23   作者:汪寧宇  
本文介紹了如何在VS2022中配置和編譯使用Boost庫(kù)的步驟,包括下載Boost、解壓、配置環(huán)境變量和編譯等過(guò)程,具有一定的參考價(jià)值,感興趣的可以了解一下

1、下載boost最新版本,以1.85為示例:

Boost Downloads

2、解壓boost文件至D:\boost_1_85_0

3、打開(kāi)VS2022命令行(紅色區(qū)域不要進(jìn)錯(cuò)了!)

4、在命令行輸入以下

5、輸入bootstrap.bat后會(huì)自動(dòng)生成b2.exe

6、待第5步完成,依次輸入這兩行命令(這里根據(jù)電腦硬件配置決定,通常3-10分鐘完畢)

# 生成32位
b2 toolset=msvc-14.3 --build-type=complete architecture=x86 address-model=32 threading=multi link=static,shared variant=debug,release stage

# 生成64位
b2 toolset=msvc-14.3 --build-type=complete architecture=x86 address-model=64 threading=multi link=static,shared variant=debug,release stage

7、命令行參數(shù)注釋(可不用理會(huì))

toolset=msvc-14.3 						指定了使用 Visual Studio 2017 編譯器。
--build-type=complete 					表示構(gòu)建所有 Boost 組件。
architecture=x86 和 address-model=32 	指定了生成 32 位架構(gòu)的庫(kù)。
architecture=x86 和 address-model=64 	指定了生成 64 位架構(gòu)的庫(kù)。
threading=multi 						表示多線程支持。
link=static,shared 						表示同時(shí)生成靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)。
variant=debug,release 					表示同時(shí)編譯調(diào)試和發(fā)布版本。

8、在使用時(shí)候,VS中需要設(shè)置以下關(guān)鍵位置:

# 頭文件目錄
D:\boost_1_85_0;

# lib庫(kù)目錄
D:\boost_1_85_0\stage\lib;

9、上面的路徑設(shè)好后,寫(xiě)一段測(cè)試代碼試試:

#include <boost/lexical_cast.hpp>     
#include <iostream>   
 
using namespace std;
using namespace boost;
 
int main(){
 
	double a = lexical_cast<double>("3.141592");
	string str = lexical_cast<string>("3.141592");
	cout << "This is a number: " << a << endl;
	cout << "This is a string: " << str << endl;
	int b = 0;
	try {
		b = lexical_cast<int>("xiaomi_su7");
	}
	catch (bad_lexical_cast& e) {
		cout << e.what() << endl;
	}
	return 0;
}

到此這篇關(guān)于VS2022配置編譯使用boost庫(kù)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)VS2022配置編譯boost庫(kù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論