Boost库的编译

来源:互联网 发布:打码软件赚钱 编辑:程序博客网 时间:2024/06/17 19:44

Boost的编译

 

. 编译环境


Win7 sp1 64位旗舰版 + VS2008 sp1 + boost 1.63

 

. 下载boost


http://www.boost.org/users/history/version_1_63_0.html

https://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.7z

 

. 生成boost的编译工具b2.exebjam.exe


3.1 解压boost_1_63_0.7zC:\boost_1_63_0  (路径可任意选择,最好不要包含中文和空格);

3.2 使用VC2008的命令行工具并cdC:\boost_1_63_0

3.3 输入bootstrap.bat

即可生成b2.exebjam.exe

 

 

. 编译boost


4.1. 编译命令


我这里是全编译:

// 编译Debug

b2.exe install --toolset=msvc-9.0 --prefix="vc9" link=static runtime-link=shared threading=multi debug

// 编译Release

b2.exe install--toolset=msvc-9.0 --prefix="vc9" link=static runtime-link=shared threading=multi release

// Debug版和Release版都编译

b2.exe install--toolset=msvc-9.0 --prefix="vc9" link=static runtime-link=shared threading=multi debug release

 

4.2. b2.exe/bjam.exe的命令参数解析


1). stage/install


stage :表示只生成库(dll/lib);

install : 除了生成库((dll/lib)),还会拷贝boost的头文件到指定的include目录;(我试过了,要拷贝一万多个头文件,很慢)


2). toolset


指定编译器, 可选的如borland, gcc, msvc(VC6), msvc-12.0(VS2013), msvc-14.0(VS2015).例如上面命令的--toolset=msvc-9.0


3). without/with


选择不编译/编译哪些库.因为我这里是全编译,所以不写.


4). stagedir/prefix


stage时使用stagedir, install时使用prefix,表示编译生成文件的路径.我这里是当前目录下的v9目录,也就是C:\boost_1_63_0\vc9


5). build-dir


编译生成的中间文件的路径. 这里没用到,默认就在根目录(X:\boost_X_XX_X\boost),目录名为bin.v2.


6). link


生成动态链接库/静态链接库.生成动态链接库需使用shared方式,生成静态链接库需使用static方式.我这里是link=static


7). runtime-link


动态/静态链接C/C++运行时库.同样有sharedstatic两种方式,这样runtime-linklink一共可以产生4种组合方式.我这里是runtime-link=shared

 

8). threading


/多线程编译.一般都写多线程程序,当然要指定multi方式了;如果需要编写单线程程序,那么还需要编译单线程库,可以使用single方式.我这里是threading=multi


9). debug/release


编译debug/release版本.我这里是debug release

 

. 配置boostVC上的路径


你懂的

 

参考:

http://www.cppblog.com/FongLuo/archive/2016/10/20/214347.html
http://www.jianshu.com/p/de1fda741beb

http://blog.sina.com.cn/s/blog_62431a790101b4ci.html

http://www.cppblog.com/HappySky2046/archive/2013/12/14/204794.html

0 0
原创粉丝点击