下載連接:https://www.boost.org/
學習連接:https://theboostcpplibraries.com/linux
cd /d "C:\Program Files (x86)\Microsoft Visual Studio\2017\boost_1_73_0" bootstrap.bat // 執行失敗須要查看bootstrap.log,成功後會獲得b2.exe, b2.exe
// 工程:屬性 =》配置屬性 =》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; }
$ sudo ./bootstrap.sh $ sudo ./b2 install // 頭文件在/usr/local/include,庫文件在/usr/local/lib
#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