当前位置: 移动技术网 > IT编程>开发语言>C/C++ > C++ boost库的安装过程详解

C++ boost库的安装过程详解

2020年07月28日  | 移动技术网IT编程  | 我要评论

windows安装boost库

下载链接:
学习链接:

1,下载解压,我的目录“c:\program files (x86)\microsoft visual studio\2017”

2,以管理员身份运行“适用于 vs 2017 的 x64 本机工具命令提示”

3,执行以下命令进行编译:

cd /d "c:\program files (x86)\microsoft visual studio\2017\boost_1_73_0"
bootstrap.bat // 执行失败需要查看bootstrap.log,成功后会得到b2.exe,
b2.exe

4,使用

// 工程:属性 =》配置属性 =》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,进入解压后的目录执行命令

$ 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

到此这篇关于c++ boost库的安装过程详解的文章就介绍到这了,更多相关c++ boost库的安装内容请搜索移动技术网以前的文章或继续浏览下面的相关文章希望大家以后多多支持移动技术网!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网