开源项目推荐:VS2010下安装和使用boost库

boost官网 http://www.boost.org/

boost下载:

https://dl.bintray.com/boostorg/release/ -- 推荐下载exe文件

https://sourceforge.net/projects/boost/files/boost-binaries/ -- 推荐下载exe文件

Asio官网 http://think-async.com/

Asio sourceforge http://sourceforge.net/projects/asio/files/

Asio samples https://github.com/mabrarov/asio_samples

1.去官网www.boost.org下载最新的boost,我下载了boost_1_55_0.zip和boost_1_55_0-msvc-10.0-32.exe。前者是纯净的源码,需要用户自己编译;后者是VS2010已编译的,含源码和编译生成的库。

2.这里只讲诉boost_1_55_0-msvc-10.0-32.exe。安装路径不建议放在C盘,例如D:\tmpcode\boost_1_55_0。安装需要3.4GB硬盘空间。

3.设置Windows的环境变量。推荐使用工具Rapid Environment Editor。http://www.rapidee.com/

环境变量,用户变量组,新建变量名:BOOST(建议使用BOOST_ROOT更好),变量值:D:\tmpcode\boost_1_55_0

4.修改VS2010的参数,在项目的解决方案那里找到属性页,打开并选择配置属性,选择VC++目录,设置包含目录和库目录,例如我的为:

包含目录$(BOOST);$(IncludePath)

库目录  $(BOOST)\lib32-msvc-10.0;$(LibraryPath) 

 

5.至此设置完毕。如果想自行编译源码boost_1_55_0.zip,请参考文章:

http://blog.csdn.net/misskissc/article/details/9793645

6.运行下面程序,测试

#include "stdafx.h"
#include <boost/config.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/tuple/tuple.hpp>
enum family
{ Jeanie, Debbie, Rick, John, Amanda, Margaret, Benjamin, N };
int main()
{
        using namespace boost;
        const char *name[] = { "Jeanie", "Debbie", "Rick", "John", "Amanda",
               "Margaret", "Benjamin"
        };
        adjacency_list <> g(N);
        add_edge(Jeanie, Debbie, g);
        add_edge(Jeanie, Rick, g);
        add_edge(Jeanie, John, g);
        add_edge(Debbie, Amanda, g);
        add_edge(Rick, Margaret, g);
        add_edge(John, Benjamin, g);
        graph_traits < adjacency_list <> >::vertex_iterator i, end;
        graph_traits < adjacency_list <> >::adjacency_iterator ai, a_end;
        property_map < adjacency_list <>, vertex_index_t >::type
               index_map = get(vertex_index, g);
        for (boost::tie(i, end) = vertices(g); i != end; ++i) {
               std::cout << name[get(index_map, *i)];
               boost::tie(ai, a_end) = adjacent_vertices(*i, g);
               if (ai == a_end)
                       std::cout << " has no children";
               else
                       std::cout << " is the parent of ";
               for (; ai != a_end; ++ai) {
                       std::cout << name[get(index_map, *ai)];
                       if (boost::next(ai) != a_end)
                               std::cout << ", ";
               }
               std::cout << std::endl;
        }
        return EXIT_SUCCESS;
}

 

推荐姊妹篇《Linux系统编译boost源码,然后和Qt Creator配套使用》 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值