VS2008安装boost进行开发

1.参考《实战准标准库Boost,配置Boost的VS2008开发环境

2.参考《VS2010安装Boost》

一、下载Boost库

boost_1_50_0.zip   (http://www.boost.org/users/download/),解压到F:boost_1_50_0

要做Python开发的还需下载: python-2.7.3.msi   (http://www.python.org/)

二、编译Boost库

1. 编译jam   

    在工具栏启动Visual Studio 2008 Command Prompt(VS2008命令提示) , 进入 boost的解压目录,即F:\boost_1_50_0, 输入bootstrap,便在boost根目录下生成bjam.exe文件。具体命令如下:

>F:\

>cd F:\boost_1_50_0

>bootstrap

   【 注:在网上看了许多教程,老版本需要进入tools/jam/目录下运行build_dist.bat 生成bjam.exe,这点与老版本不同。】

2. 编译boost

     如果需要去掉编译过程中的一些warning,可以在tools\build\v2的user-config.jam文件中加入以下这一行:
    using msvc : : : <compileflags>/wd4819 <compileflags>/D_CRT_SECURE_NO_DEPRECATE <compileflags>/D_SCL_SECURE_NO_DEPRECATE    <compileflags>/D_SECURE_SCL=0 ;

  然后双击bjam.exe;——时间有些长,请耐心等待

三、配置VS2008开发环境

在菜单栏的“工具”——“选项”——“项目和解决方案”——“VC++目录”,“平台”选择“Win32”。

“显示以下内容的目录”选择“库文件”,点击“新建”按钮,文件夹选择“F:\boost_1_50_0\stage\lib”

“显示以下内容的目录”选择“包含文件”,点击“新建”按钮,文件夹选择“F:\boost_1_50_0”

四、代码测试

  1. #include <stdlib.h>  
  2. #include <boost/config.hpp>  
  3. #include <iostream>  
  4. #include <vector>  
  5. #include <string>  
  6. #include <boost/graph/adjacency_list.hpp>  
  7. #include <boost/tuple/tuple.hpp>  
  8. enum family  
  9. { Jeanie, Debbie, Rick, John, Amanda, Margaret, Benjamin, N };  
  10. int main()  
  11. {  
  12.     using namespace boost;  
  13.     const char *name[] = { "Jeanie""Debbie""Rick""John""Amanda",  
  14.         "Margaret""Benjamin"  
  15.     };  
  16.   
  17.     adjacency_list <> g(N);  
  18.     add_edge(Jeanie, Debbie, g);  
  19.     add_edge(Jeanie, Rick, g);  
  20.     add_edge(Jeanie, John, g);  
  21.     add_edge(Debbie, Amanda, g);  
  22.     add_edge(Rick, Margaret, g);  
  23.     add_edge(John, Benjamin, g);  
  24.   
  25.     graph_traits < adjacency_list <> >::vertex_iterator i, end;  
  26.     graph_traits < adjacency_list <> >::adjacency_iterator ai, a_end;  
  27.     property_map < adjacency_list <>, vertex_index_t >::type  
  28.         index_map = get(vertex_index, g);  
  29.   
  30.     for (boost::tie(i, end) = vertices(g); i != end; ++i) {  
  31.         std::cout << name[get(index_map, *i)];  
  32.         boost::tie(ai, a_end) = adjacent_vertices(*i, g);  
  33.         if (ai == a_end)  
  34.             std::cout << " has no children";  
  35.         else  
  36.             std::cout << " is the parent of ";  
  37.         for (; ai != a_end; ++ai) {  
  38.             std::cout << name[get(index_map, *ai)];  
  39.             if (boost::next(ai) != a_end)  
  40.                 std::cout << ", ";  
  41.         }  
  42.         std::cout << std::endl;  
  43.     }  
  44.     system("pause");  
  45.     return EXIT_SUCCESS;  
  46. }  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值