VS2013下安装Boost库

川长思鸟来 2022-07-26 00:08 337阅读 0赞

本文讲解在VS2013中编译和配置Boost库。

1.下载并解压 Boost

到Boost的官网上下载http://www.boost.org/users/history/version\_1\_60\_0.html,这里选择的是最新版的boost

Center

下载后解压到本地目录中,

Center 1

以管理员身份执行boostrap.bat文件,执行完成之后会生成bjam.exe文件。

  1. 编译boost

在命令行中执行bjam.exe程序,此时会根据系统安装的msvc进行编译,

Center 2

编译过程较长,需要等待一段时间,编译完成之后将会显示如下内容

Center 3

  1. 在项目中使用boost

在VS2013 中新建一个VC++控制台程序的空项目,新建一个mian.cpp文件,在文件中输入以下内容:

  1. #include <boost/lexical_cast.hpp>
  2. #include <boost/lambda/lambda.hpp>
  3. #include <iostream>
  4. #include <string>
  5. #include <iterator>
  6. #include <algorithm>
  7. using namespace std;
  8. int main()
  9. {
  10. using boost::lexical_cast;
  11. int a = lexical_cast<int>("123");
  12. double b = lexical_cast<double>("123.0123456789");
  13. string s0 = lexical_cast<string>(a);
  14. string s1 = lexical_cast<string>(b);
  15. cout << "Number: " << a << endl;
  16. cout << "string: " << s0 << endl;
  17. int c = 0;
  18. try
  19. {
  20. c = lexical_cast<int>("abcd");
  21. }
  22. catch (boost::bad_lexical_cast& e)
  23. {
  24. cout << e.what() << endl;
  25. }
  26. using namespace boost::lambda;
  27. typedef std::istream_iterator<int> in;
  28. std::for_each(in(std::cin),in(), std::cout<<(_1*3)<< " ");
  29. system("pause");
  30. return 0;
  31. }

在项目属性中配置如下内容:

包含目录添加 G:\boost_1_60_0

库目录添加 G:\boost_1_60_0\stage\lib

执行程序,结果如下:

Center 4

发表评论

表情:
评论列表 (有 0 条评论,337人围观)

还没有评论,来说两句吧...

相关阅读

    相关 vs2013使用opencv静态

    使用VS2013和opencv进行图像处理程序的开发,当把程序放到一台没有安装opencv的电脑上运行的时候,需要重新安装opencv程序才能运行,这样会显得很麻烦,使用ope