Windows 7 64bit和Visual Studio 2010下安装及使用Boost 1.47.0

本文详细介绍如何安装及使用Boost1.47.0库,包括下载、构建库文件及在Visual Studio环境中设置所需的配置步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文出处:http://blog.sina.com.cn/s/blog_6e0693f70100txlg.html

其他参考:

http://www.cnblogs.com/wondering/archive/2009/05/21/boost_setup.html



Boost库是一个经过千锤百炼、可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一。 Boost库由C++标准委员会库工作组成员发起,在C++社区中影响甚大,其成员已近2000人。本文主要介绍了如何安装及使用Boost 1.47.0。

参考网页: http://tech.ddvip.com/2009-05/1242887529120322.html

       1). 在 http://www.boost.org/users/download/ 下载最新版Boost库。解压后将其复制到指定位置。

       2). 打开Visual Studio Command Prompt,进入解压后的Boost目录。输入bootstrap,等待其生成Boost构建工具bjam。
Windows <wbr>7 <wbr>64bit和Visual <wbr>Studio <wbr>2010下安装及使用Boost <wbr>1.47.0
       3). 在命令行输入bjam toolset=msvc-10.0 variant=debug,release threading=multi link=static 。然后等待安装完成。如果要生成64位库,键入命令bjam toolset=msvc-10.0 variant=debug,release threading=multi link=static address-model=64。 Windows <wbr>7 <wbr>64bit和Visual <wbr>Studio <wbr>2010下安装及使用Boost <wbr>1.47.0
       4). 安装完成后,屏幕上会提示"The Boost C++ Libraries were successfully built!"。并制定头文件和库文件目录。 Windows <wbr>7 <wbr>64bit和Visual <wbr>Studio <wbr>2010下安装及使用Boost <wbr>1.47.0
       5). 新建一个win32控制台程序,命名为Boost_Test。代码后附。

       6). 在Project -> Boost_Test Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories 中增加头文件路径。 Windows <wbr>7 <wbr>64bit和Visual <wbr>Studio <wbr>2010下安装及使用Boost <wbr>1.47.0
       7). 在Project -> Boost_Test Properties -> Configuration Properties -> Linker -> General -> Additional Library Directories 中增加库文件路径。这里我们不用制定需要链接的静态库,Boost会自动加载需要的库文件。 Windows <wbr>7 <wbr>64bit和Visual <wbr>Studio <wbr>2010下安装及使用Boost <wbr>1.47.0
       8). 编译,链接,测试结果如下。
Windows <wbr>7 <wbr>64bit和Visual <wbr>Studio <wbr>2010下安装及使用Boost <wbr>1.47.0
Boost_Test.cpp代码
// Boost_Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
using namespace std;
struct Hello
{
       Hello()
       {
              cout << "Hello constructor" << endl;
       }

       ~Hello()
       {
              cout << "Hello destructor" << endl;
              cin.get();
       }
};
int _tmain(int argc, _TCHAR* argv[])
{
       boost::regex regex("^(Hello|Bye) Boost$");
       boost::cmatch helloMatches;
       boost::regex_search("Hello Boost", helloMatches, regex);
       cout << "The word between () is: " << helloMatches[1] << endl;
       boost::shared_ptr<Hello> sharedHello(new Hello);
       cin.get();
       return 0;

}



Snowwolf_Yang注:

VC2010编译提示 LINK : fatal error LNK1104: 无法打开文件“libboost_system-vc100-mt-gd-1_51.lib”

这个错误应该是lib路径没写对:/stage/lib


项目\属性\配置属性\清单工具\输入和输出\嵌入清单:原来是“是”,改成“否”。
和
项目->属性->配置属性->C/C++ -> 预处理器 -> 预处理器定义,增加_CRT_SECURE_NO_DEPRECATE 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值