您的位置:首页 > 其它

VS2008 安装 Boost 1.43.0

2011-03-13 14:22 225 查看
1.打开 www.boost.org 下载最新版本 1.43.0, 解压至 C 盘根目录。

2.打开 Visual Studio 2008 命令提示窗口

3.进入 C:\boost_1_43_0\tools\jam\src

4.执行 build.bat ,会在 C:\boost_1_43_0\tools\jam\src\bin.ntx86 生成 bjam.exe 文件,复制 bjam.exe 文件到 C:\boost_1_43_0 下。

5.修改 C:\boost_1_43_0\tools\build\v2\user-config.jam 找到下面的文字

# -------------------
# MSVC configuration.
# -------------------

# Configure msvc (default version, searched for in standard locations and PATH).
# using msvc ;

# Configure specific msvc version (searched for in standard locations and PATH).
# using msvc : 8.0 ;

#在这里添加 vs2008 的配置

using msvc : 9.0 : : /wd4819 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 ;

6.进入 C:\boost_1_43_0 目录

7.执行bjam.exe 编译命令

bjam --without-python --toolset=msvc-9.0 --prefix=c:\boost install(不起作用???)

等待编译完成,会很久。

8.新建一个空的 win32 console application 工程,tools->options->projects and solutions->VC++ directories,添加

include files:c:\boost\include\boost-1_43_0
library files: c:\boost\lib

注:编译成功后会有提示

The Boost C++ Libraries were sucessfully built!
The following directory should be added to compiler include paths: C:\boost_1_43_0The following directory should be added to link library paths: C:\boost_1_43_0\stage\lib

故:

include files:C:\boost_1_43_0

library files: C:\boost_1_43_0\stage\lib 或者把

C:\boost_1_43_0目录下的文件(boost文件夹)添加至VS2008 include目录下(例G:\Program Files\Microsoft Visual Studio 9.0\VC\include)

C:\boost_1_43_0\stage\lib目录下的所有lib、dll文件添加到VS2008 lib目录下(例G:\Program Files\Microsoft Visual Studio 9.0\VC\lib)

这两步做完后就无须设置tools->options->projects and solutions->VC++ directories

9.测试, win32 console application

#include "stdafx.h"
#include <boost/lexical_cast.hpp>
#include <iostream>

using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
using boost::lexical_cast;

int a=lexical_cast<int>("123");
double b=lexical_cast<double>("123.0123456789");
string s0=lexical_cast<string>(a);
string s1=lexical_cast<string>(b);
cout<<"number: "<<a<<" "<<b<<endl;
cout<<"string: "<<s0<<" "<<s1<<endl;
int c=0;
try{
c=lexical_cast<int>("abcd");
}
catch(boost::bad_lexical_cast& e)
{
cout<<e.what()<<endl;
}
return 0;
}

本文转自:http://www.cnblogs.com/sudoleo/archive/2010/07/16/1778522.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: