Boost 1_42_0在windows下的编译及其设置
来源:互联网 发布:录音大师软件下载 编辑:程序博客网 时间:2024/06/05 09:51
http://www.cnblogs.com/kex1n/archive/2010/03/24/2286507.html
1. 首先在http://sourceforge.net/projects/boost/files/boost/1.42.0/ 下载boost库的最新版本boost_1_42。注意要把boost库放在一个至少有6个g空间的硬盘编译。
2. 下载后使用命令行进入boost库的根目录(我的为:E:/boost_1_42_0)。
3. 在命令行窗口运行boost库的根目录的批处理文件:bootstrap.bat生成bjam工具。 (直接在解压目录下双击bootstrap.bat即可)
4. 运行命令:bjam -sBOOST_ROOT=. -sTOOLS=msvc "--build-type=complete"
(上述命令需要在boost解压文件的含有bjam的目录下运行,比如:
进入cdm后:
1、d: (我解压在D盘)
2、cd softwares/boost_1_42_0/boost_1_42_0/
3、bjam -sBOOST_ROOT=. -sTOOLS=msvc "--build-type=complete"
)
注意这是完全编译boost库,包括单线程、多线程、unicode和非unicode版本。因为我觉得以后的需求是不确定的,干脆一次性编译好了。还有上面的命令行参数稍微说明一下:
-sBOOST_ROOT=.表明boost库的根目录在当前目录。-sTOOLS=msvc表示使用VC 编译器进行编译,如果你机子上装有多个版本的VC,那么会选择最高版本的编译器进行编译(如装有VC6.0、VC 8.0,那么肯定是选择VC 8.0的编译器进行编译)。--build-type=complete表明是完全编译,包括各种版本。
编译完成后就是在VC或者VS中的设置问题了。
我的路径是:d:/softwares/boost 1_42_0/boost 1_42_0/*
其中刚才编译的库文件在d:/softwares/boost 1_42_0/boost 1_42_0/stage/lib中。
进行如下设置:
1.include directory 中包含根目录d:/softwares/boost 1_42_0/boost 1_42_0/。
2.library include 中包含d:/softwares/boost 1_42_0/boost 1_42_0/stage/lib。
3.source include 中包含d:/softwares/boost 1_42_0/boost 1_42_0/boost。
OK,boost可以用了。。。。
----------------------------------------------------------------------------------------------------------------------------------------------------------
在Win32系统上编译Boost,我们以winxp为例:
boost中包含一个类似于make/nmake的工具:bjam,这是boost所推荐的编译方式,
我们就用bjam来编译boost,而bjam的源码也包含在boost的源码包中。
1. 先编译bjam
a) 将boost源码包解包,我们设BOOST_ROOT代表解包后boost的根目录。
...
D:\>cd d:\svn\boost-trunk\
D:\svn\boost-trunk\>
b) 到达bjam的源码目录: $(BOOST_ROOT)\tools\jam\src\
...
D:\svn\boost-trunk>cd tools\jam\src
D:\svn\boost-trunk\tools\jam\src>
c) 然后通过执行其中的build.bat来编译bjam, 这个脚本在执行时可以带一个参数,
用来指定编译bjam的编译器, 如果不带任何参数会自动检查当前系统中已安装的编译
器。当前boost在windows平台所支持的编译工具选项有:
borland:
como:
gcc:
gcc-nocygwin:
intel-win32:
metrowerks:
mingw:
msvc: 用VC6.0进行编译
vc7:
vc8:
vc9:
我们让build.bat自己检查,由于我机器上同时安装了vc6.0与vc7.0,build.bat在
自动检查时会从最新的版进行尝试,所以它会用vc7.0编译bjam:
D:\svn\boost-trunk\tools\jam\src>build.bat
"Call_If_Exists"
Setting environment for using Microsoft Visual Studio .NET 2003 tools.
(If you have another version of Visual Studio or Visual C++ installed and wish
to use its tools from the command line, run vcvars32.bat for that version.)
###
### Using 'vc7' toolset.
###
D:\svn\boost-trunk\tools\jam\src>rd /S /Q bootstrap
...
...
...
updated 1 target...
D:\svn\boost-trunk\tools\jam\src>
d) 得到编译好的bjam,编译完成后就会在当前目录下生在一个保存编译结果的目录: bin.平台类型
我的当前的系统是x86上的winxp(nt),所以这个目录为:bin.ntx86,编译好的bjam就保存在这个
目录下:bjam.exe
2. 先用bjam编译boost中的一个库试试,我们就试试编译test库吧。
a) 通过命令行,到达test的库代码目录:
...
D:\>cd svn\boost-trunk\libs\test
D:\svn\boost-trunk\libs\test>
b) 在这个目录下有一个文件:Jamfile.v2,bjam.exe通过这个文件来了解如何编译test,它类似与
make/nmake的Makefile文件,我们在这个目录直接调用bjam.exe,就可以编译test:
D:\svn\boost-trunk\libs\test>..\..\tools\jam\src\bin.ntx86\bjam.exe
warning: Graph library does not contain optional GraphML reader.
note: to enable GraphML support, set EXPAT_INCLUDE and EXPAT_LIBPATH to the
note: directories containing the Expat headers and libraries, respectively.
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
...
...
**passed** ..\..\bin.v2\libs\test\example\unit_t...
test
...failed updating 2 targets...
...skipped 2 targets...
...updated 434 targets...
c) 默认会编译debug版,且会编译和调用所有单元测试,编译出来的二进制会保存在:
$(BOOST_ROOT)\bin.v2:
D:\svn\boost-trunk>cd bin.v2
D:\svn\boost-trunk\bin.v2>tree
文件夹 PATH 列表
卷序列号码为 000007BC 6057:AC36
D:.
└─libs
├─test
│ ├─build
│ │ └─msvc-7.1
│ │ └─debug
│ │ └─asynch-exceptions-on
│ │ ├─link-static
│ │ │ └─threading-multi
│ │ └─threading-multi
│ ├─example
│ │ ├─const_string_test.test
│ │ │ └─msvc-7.1
│ │ │ └─debug
│ │ │ └─threading-multi
│ │ ├─est_example1.test
│ │ │ └─msvc-7.1
│ │ │ └─debug
│ │ │ └─threading-multi
│ │ ├─est_example2.test
│ │ │ └─msvc-7.1
│ │ │ └─debug
│ │ │ └─threading-multi
│ │ ├─exec_mon_example.test
│ │ │ └─msvc-7.1
...........
3. 编译整个boost:
a) 在boost的根目录下有一个文件:Jamroot,我们在boost根目录下直接执行bjam.exe,就可以
能过这个文件编译根个boost库。
D:\svn\boost-trunk>tools\jam\src\bin.ntx86\bjam.exe
warning: Graph library does not contain optional GraphML reader.
note: to enable GraphML support, set EXPAT_INCLUDE and EXPAT_LIBPATH to the
note: directories containing the Expat headers and libraries, respectively.
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
.......
b) Jamroot文件中有很多可用的编译选项,可以用文件编辑器打开这个文件,来了解更从的编译细节。
例如,可以通过参数来有选择的编译(或不编译)boost的中指定库,如测试库:
D:\svn\boost-trunk>tools\jam\src\bin.ntx86\bjam.exe --with-teststage
- Boost 1_42_0在windows下的编译及其设置
- 在Windows下编译Boost
- “Windows下编译boost程序库”和“使用boost库的编译环境的设置”
- BOOST库的在windows下的编译小记
- boost 在windows下的编译及使用
- C++ Boost在Windows和Linux下的编译安装
- C++ Boost在Windows和Linux下的编译安装
- boost库在windows下的编译和使用
- 在windows下编译boost 1.32库
- [boost] Windows下编译
- Windows下boost安装及其在VS2013中配置
- Windows下boost安装及其在VS2013中配置
- Windows下boost安装及其在VS2013中配置
- windows 下boost库的简单编译
- windows下!boost库的编译选项
- 在ubuntu上编译boost,boost的安装目录设置
- boost 1_49_0 在linux 下的 编译 安装
- Boost在VS2008下的正确编译
- java ServerSocket API 详解
- 关于手机唯一识别码的研究meid和imei
- Linux入门:开机进入文本界面
- 快排函数详解
- ASP.NET中使用框架
- Boost 1_42_0在windows下的编译及其设置
- ymPrompt
- javascript与ASP:Button中onclick问题
- GDB+GDBServer方式进行ARM程序调试
- C++ 虚函数表解析
- 黑马程序员____基本类型
- C语言中有关string的函数详解
- NO.82 高并发、海量数据项目的数据库选型考量点分析
- 什么是套接字