0条评论
还没有人评论过~
下载链接:https://www.boost.org/
学习链接:https://theboostcpplibraries.com/
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