[普通]boost工程

作者(passion) 阅读(1010次) 评论(0) 分类( boost)

1. www.boost.org下载最新的boost,我下载了boost_1_46_1.7z

2.(我放在D:/cpp目录下)解压到当前文件夹

3. 打开VS2010->VS TOOLS->VS命令提示

4. CD D:/cpp/boost_1_46_1 

5. 输入bootstrap,便生成bjam.exe文件

6  bjam --toolset=msvc-15.0 --build-type=complete 完全编译

7 设定vs2017环境。
(注:在2017环境下这步,
在项目-->右键属性-->VC++ Directories 中去填写对应路径 ) 
Tools -> Options -> Projects and Solutions -> VC++ Directories 
  
在Library Directories加上d:boost\boost_1_46_1  
       
在Include Directories加上d:boost\boost_1_46_1\stage\lib

8也可创建环境变量
BOOST_ROOT_INC=d:boost\boost_1_46_1 
BOOST_ROOT_LIB =d:boost\boost_1_46_1\stage\lib

#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;
}


« 上一篇:wifi共享上网(至尊版wifi)
« 下一篇:ASP.NET附加数据库文件的方式,如何发布到IIS7而不导致SQLServer出错
在这里写下您精彩的评论
  • 微信

  • QQ

  • 支付宝

返回首页
返回首页 img
返回顶部~
返回顶部 img