C++ boost庫的安裝過程詳解
Windows安裝boost庫
下載鏈接:https://www.boost.org/
學(xué)習(xí)鏈接:https://theboostcpplibraries.com/
1,下載解壓,我的目錄“C:\Program Files (x86)\Microsoft Visual Studio\2017”
2,以管理員身份運行“適用于 VS 2017 的 x64 本機工具命令提示”
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++中strcpy函數(shù)在VS2015無法使用的問題
這篇文章主要介紹了c++中strcpy函數(shù)在VS2015無法使用的問題,具有一定的參考價值,有需要的可以了解一下。2016-11-11