windows 下编译 Boost 1.50 + Visual Studio 2008

 

1、在c盘创建一个文件夹boost_1_50_0

2、下载最新的boost 库1.50到d盘,文件夹为boost_1_50_0

3、整个文件夹如下:

D:\>cd boost_1_50_0

D:\boost_1_50_0>dir
 Volume in drive D is D
 Volume Serial Number is 7CF4-5846

 Directory of D:\boost_1_50_0

2012/07/19  21:13    <DIR>          .
2012/07/19  21:13    <DIR>          ..
2012/07/19  21:10    <DIR>          boost
2012/05/27  03:33               866 boost-build.jam
2012/05/27  03:33             1,054 boost.css
2012/05/27  03:33             6,308 boost.png
2012/06/26  22:07            18,606 boostcpp.jam
2012/05/27  03:33             2,545 bootstrap.bat
2012/05/27  03:33            10,324 bootstrap.sh
2012/07/19  21:10    <DIR>          doc
2012/05/27  03:33               794 index.htm
2012/05/27  03:33             5,848 index.html
2012/05/27  03:33               298 INSTALL
2012/05/27  03:33            10,423 Jamroot
2012/07/19  21:13    <DIR>          libs
2012/05/27  03:33             1,361 LICENSE_1_0.txt
2012/07/19  21:13    <DIR>          more
2012/05/27  03:33             2,757 rst.css
2012/07/19  21:13    <DIR>          status
2012/07/19  21:13    <DIR>          tools
              12 File(s)         61,184 bytes
               8 Dir(s)  52,751,728,640 bytes free

D:\boost_1_50_0>


 

4、开启vc2008的自带的cmd工具,开始如下操作:

D:\boost_1_50_0>cd tools\build\v2

D:\boost_1_50_0\tools\build\v2>bootstrap.bat
Bootstrapping the build engine

Bootstrapping is done. To build, run:

    .\b2 --prefix=DIR install


D:\boost_1_50_0\tools\build\v2>


 

5、不要按照它的操作提示来,我们回到根目录,执行b2.exe操作,这个操作需要到根目录下面做,自然就要使用相对路径call b2.exe,同时指定编译工具为msvc 9.0,以后安装的路径,c:\boost_1_50_0:

D:\boost_1_50_0\tools\build\v2>cd ../../..

D:\boost_1_50_0>tools\build\v2\b2.exe toolset=msvc-9.0 --build-type=complete --prefix="c:\boost_1_50_0" stage
Performing configuration checks


6、执行安装过程:

D:\boost_1_50_0>tools\build\v2\b2.exe toolset=msvc-9.0 --build-type=complete --prefix="c:\boost_1_50_0" install


 

一切ok。

 

下一步就是测试是否ok了。

 

添加vc项目头文件和lib路径:

 

测试一个网络上下载的的代码:

 

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
boost::asio::deadline_timer t1(io, boost::posix_time::seconds(3));


void print(const boost::system::error_code& e)
//要求回调函数必须具有该参数
{
    if (e)
    {
        std::cout << "Hello, error!/n";
    }
    std::cout << "Hello, world!/n";
}

void cancel(const boost::system::error_code&)
{
    t.cancel();
}

int main()
{

    t.async_wait(print);
    t1.async_wait(cancel);

    io.run();
    return 0;
}


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值