MinGW 环境Boost库的编译及安装

来源:互联网 发布:黑客牛还是程序员厉害 编辑:程序博客网 时间:2024/05/01 11:16

MinGW:MinGW是指只用自由软件来生成纯粹的Win32可执行文件的编译环境,它是Minimalist GNU on Windows的略称。

Boost库:是一个可移植、提供源代码的C++库,是C++标准化进程的发动机之一。官方网站为http://www.boost.org/,目前最新版本为1.46.0。

 

1、安装CodeBlocks 10.05版本  http://www.codeblocks.org/ 

 

2、在系统环境变量PATH中添加路径

<%Code::Blocks安装目录%>/MinGW/bin;

<%Code::Blocks安装目录%>/MinGW/libexec/gcc/mingw32/4.4.1;

开始->运行->输入"cmd"回车->cmd窗口"gcc -v"查看gcc版本信息,如果看到如下类似输出,那么就可以继续编译Boost了。

Using built-in specs.

Target: mingw32

Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --ena

ble-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-regis

try --enable-libgomp --enable-cxx-flags='-fno-function-sections -fno-data-sectio

ns' --disable-werror --enable-threads --disable-symvers --enable-version-specifi

c-runtime-libs --enable-fully-dynamic-string --with-pkgversion='TDM-2 mingw32' -

-enable-sjlj-exceptions --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php

Thread model: win32

gcc version 4.4.1 (TDM-2 mingw32)

 

3、生成bjam.exe

在cmd窗口切换到如下目录"E:/work/boost_1_46_0/tools/build/v2/engine/src"下,使用命令"build mingw",会在此目录下生成文件bin.ntx86/bjam.exe,将bjam.exe拷贝到boost源文件的根目录下,如"E:/_Libs_/boost_1_46_0/"。在这个目录下的"Jamroot"文件,详细描述了bjam的用法。

 

4、编译

执行bjam install --toolset=gcc --prefix="<%boost安装目录%>" debug --without-wave --without-mpi --without-python --without-math --without-graph 编译debug版;

 

执行bjam install --toolset=gcc --prefix="<%boost安装目录%>" debug --without-wave --without-mpi --without-python --without-math --without-graph 编译release版。

 

bjam  --build-type=complete toolset=gcc stage
上面的命令将编译所有需要编译的子库(除python)的各种版本

 

5.在Code::Blocks中新建命令行工程

Settings-〉Compiler and debugger settings-〉Linker settings -〉<%boost安装目录%>/lib/*.lib

Settings-〉Compiler and debugger settings-〉Search directories -> Compiler -〉<%boost安装目录%>/include/boost-1_39

Settings-〉Compiler and debugger settings-〉Search directories -> Linker -〉<%boost安装目录%>/lib

 

 

原创粉丝点击