[转文]VS2008 安装 Boost 1.43.0

1.打开 www.boost.org 下载最新版本 1.43.0, 解压至 D 盘根目录。

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

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

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

5.修改 D:\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.进入 D:\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

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

转载于:https://www.cnblogs.com/CodeKnight/archive/2010/08/07/1794644.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值