用Python(x,y)安装的MinGW32编译boost

参考

http://www.cppblog.com/xinus/archive/2011/03/01/build_boost_using_mingw.html

http://blog.csdn.net/feiyunw/article/details/5593743

 

一、Windows下安装Python(x,y)时会安装MinGW32

比如查看

C:\MinGW32-xy目录会发现MinGW32已经安装

查看C:\MinGW32-xy\include目录会发现没有boost

二、下载获取boost解压

官方网址http://www.boost.org/

boost目前最新版本为1.49

三、编译前准备

bjam是boost自带的工具,用来方便地编译boost

在"<解压目录>\boost_1_49_0\tools\build\v2\engine\src"下,使用命令"build mingw",会在此目录下生成文件bin.ntx86\bjam.exe b2.exe

将bjam.exe和b2.exe 拷贝到boost源文件的根目录下,如" <解压目录> \boost_1_49_0\"。

在这个目录下的"./Jamroot"文件,详细描述了bjam的用法,建议用文本打开这个文件并阅读前面部分的注释

四、编译

bjam.exe --with-thread --with-filesystem --with-system --with-program_options --with-date_time --with-regex --prefix=.\ --layout=tagged toolset=gcc variant=release install

五、拷贝文件

吧<解压目录>\boost_1_49_0目录下的lib和include中的文件对应拷贝到C:\MinGW32-xy下的lib和include文件夹中

六、测试代码

 抄啦

http://stackoverflow.com/questions/999120/c-hello-world-boost-tee-example-program

#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/stream.hpp>
#include <fstream>
#include <iostream>

using std::ostream;
using std::ofstream;
using std::cout;

namespace bio = boost::iostreams;
using bio::tee_device;
using bio::stream;

int main()
{
    typedef tee_device<ostream, ofstream> TeeDevice;
    typedef stream<TeeDevice> TeeStream;
    ofstream ofs("sample.txt");
    TeeDevice my_tee(cout, ofs); 
    TeeStream my_split(my_tee);
    my_split << "Hello, World!\n";
    my_split.flush();
    my_split.close();
}

编译运行

g++  hello.cpp -o hello.exe

 

 

 补充

http://blog.csdn.net/yangry/article/details/6614602

要完全编译boost库需要先准备一些第三方库: 

1. Regex所需Unicode支持类库 -- ICU

2. Graph所需的Xml处理类库 --Expat

3.Boost.MPI所需MPI类库 -- Boost的官方站点说需要MPICH或OpenMPI之类的支持,事实上在Windows下总是会提示需要MPIC++,事实上你需要的是Microsoft Cluster Pack SDK


转载于:https://my.oschina.net/u/559991/blog/61643

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值