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

参考html

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

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

 

1、Windows下安装Python(x,y)时会安装MinGW32测试

好比查看ui

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

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

2、下载获取boost解压code

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

boost目前最新版本为1.49blog

3、编译前准备

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的用法,建议用文本打开这个文件并阅读前面部分的注释

4、编译

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

5、拷贝文件

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

6、测试代码

 抄啦

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

相关文章
相关标签/搜索