C++ boost庫的安裝過程詳解
Windows安裝boost庫
下載鏈接:https://www.boost.org/
學(xué)習(xí)鏈接:https://theboostcpplibraries.com/
1,下載解壓,我的目錄“C:\Program Files (x86)\Microsoft Visual Studio\2017”
2,以管理員身份運(yùn)行“適用于 VS 2017 的 x64 本機(jī)工具命令提示”
3,執(zhí)行以下命令進(jìn)行編譯:
cd /d "C:\Program Files (x86)\Microsoft Visual Studio\2017\boost_1_73_0" bootstrap.bat // 執(zhí)行失敗需要查看bootstrap.log,成功后會得到b2.exe, b2.exe
4,使用
// 工程:屬性 =》配置屬性 =》C/C++ =》常規(guī) =》附加包含目錄 填上:C:\Program Files (x86)\Microsoft Visual Studio\2017\boost_1_73_0 // 工程:屬性 =》配置屬性 =》鏈接器 =》常規(guī) =》附加庫目錄 填上:C:\Program Files (x86)\Microsoft Visual Studio\2017\boost_1_73_0\stage\lib #include <iostream> #include <string> #include <boost/filesystem.hpp> using namespace boost::filesystem; int main(int argc, char* argv[]) { std::string file; std::cin >> file; std::cout << file << " : " << file_size(file) << std::endl; return 0; }
Linux安裝boost庫
1,下載解壓
2,進(jìn)入解壓后的目錄執(zhí)行命令
$ sudo ./bootstrap.sh $ sudo ./b2 install // 頭文件在/usr/local/include,庫文件在/usr/local/lib
3,使用
#include <iostream> #include <boost/filesystem.hpp> using namespace boost::filesystem; int main(int argc, char *argv[]) { if (argc < 2) { std::cout << "用法:app path\n"; return 1; } std::cout << argv[1] << ":" << file_size(argv[1]) << std::endl; return 0; } // 編譯命令:g++ TestBoostLib.cpp -o Test -I /usr/local/include -static -L /usr/local/lib -lboost_system -lboost_filesystem
到此這篇關(guān)于C++ boost庫的安裝過程詳解的文章就介紹到這了,更多相關(guān)C++ boost庫的安裝內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C++實現(xiàn)LeetCode(67.二進(jìn)制數(shù)相加)
這篇文章主要介紹了C++實現(xiàn)LeetCode(67.二進(jìn)制數(shù)相加),本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07C++編寫DLL動態(tài)鏈接庫的步驟與實現(xiàn)方法
這篇文章主要介紹了C++編寫DLL動態(tài)鏈接庫的步驟與實現(xiàn)方法,結(jié)合實例形式分析了C++導(dǎo)出類文件及生成與調(diào)用DLL動態(tài)連接庫的相關(guān)操作技巧,需要的朋友可以參考下2016-08-08淺談stringstream 的.str()正確用法和清空操作
下面小編就為大家?guī)硪黄獪\談stringstream 的.str()正確用法和清空操作。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12