VS2010下安裝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-10.0 variant=debug,release threading=multi link=static,便生成boost庫(時間挺長20分鍾以上)

7.修改VS2010的參數 在項目的組合顯示那找到屬性頁,打開屬性頁,選擇配置屬性,選擇VC++目錄,設置includepath和libpath,

如我的為D:/cpp/boost_1_46_1;$(IncludePath)

D:/cpp/boost_1_46_1/stage/lib;$(LibraryPath)

 

 

 

至此設置完畢

 

運行下面程序

 

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

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM