用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

相關文章
相關標籤/搜索