VS2010安装boost

1,下载boost_1_58_0,下载地址http://www.boost.org/

2,解压下载的压缩包,以我使用的路径E:\Boost_VS2010\boost_1_58_0为例

3,启动Visual Studio 命令提示(2010),启动后会出现一个控制台界面。启动方法:开始->程序->MicrosoftVisual Studio 2010->Visual Studio Tools->Visual Studio 命令提示(2010)

4,进入boost目录。

命令:E:回车,进入E:盘根目录

命令:cd E:\Boost_VS2010\boost_1_58_0回车进入boost解压目录

5,输入命令bootstrap.bat回车,完成后会生成b2.exe和bjam.exe

6,输入命令b2回车,此命令执行过程会比较长

7,测试

新建空的win32控制台程序做测试,配置工程属性

7.1 属性=》配置属性=》C/C++=》常规=》附加包含目录  增加E:\Boost_VS2010\boost_1_58_0

7.2 属性=》配置属性=》链接器=》常规=》附加库目录  增加E:\Boost_VS2010\boost_1_58_0\stage\lib

7.3 测试代码示例:

#include <iostream>
#include <vector>
#include <string>
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/tuple/tuple.hpp>

enum family
{ 
	Jeanie, Debbie, Rick, John, Amanda, Margaret, Benjamin, N
};

int main(int argc, char* argv[])
{
	const char *name[] = { "Jeanie", "Debbie", "Rick", "John", "Amanda", "Margaret", "Benjamin"};
	boost::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);
	boost::graph_traits < boost::adjacency_list <> >::vertex_iterator i, end;
	boost::graph_traits < boost::adjacency_list <> >::adjacency_iterator ai, a_end;
	boost::property_map < boost::adjacency_list <>, boost::vertex_index_t >::type
		index_map = get(boost::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 0;
}

8,补充:

8.1  运行若出错,则有可能是包含目录或者库路径设置问题,请确定路径正确性

8.2 下载的boost压缩包中有boost相关资料,可以参考学习
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值