windows安裝boost庫
下載鏈接:https://www.boost.org/
學習鏈接:https://theboostcpplibraries.com/
1,下載解壓,我的目錄“c:\program files (x86)\microsoft visual studio\2017”
2,以管理員身份運行“適用于 vs 2017 的 x64 本機工具命令提示”
3,執行以下命令進行編譯:
1
2
3
|
cd /d "c:\program files (x86)\microsoft visual studio\2017\boost_1_73_0" bootstrap.bat // 執行失敗需要查看bootstrap.log,成功后會得到b2.exe, b2.exe |
4,使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// 工程:屬性 =》配置屬性 =》c/c++ =》常規 =》附加包含目錄 填上:c:\program files (x86)\microsoft visual studio\2017\boost_1_73_0 // 工程:屬性 =》配置屬性 =》鏈接器 =》常規 =》附加庫目錄 填上: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,進入解壓后的目錄執行命令
1
2
|
$ sudo ./bootstrap.sh $ sudo ./b2 install // 頭文件在/usr/local/include,庫文件在/usr/local/lib |
3,使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#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 |
到此這篇關于c++ boost庫的安裝過程詳解的文章就介紹到這了,更多相關c++ boost庫的安裝內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://www.cnblogs.com/fabric-summoner/p/13376967.html