获取Boost库源码
可以从http://www.boost.org/获取,如果下载过慢,只能去找百度了。
下载好后,解压到自己想要的目录下。
获取bjam
2:在boost目录下,找到build.bat。不同版本,放置的位置可能不同。推荐直接进行搜索。
我使用的是版本为:
boost_1_39_0。我的路径为:C:\ProgramData\Dokumente\boost_1_39_0\tools\jam\src\build.bat.
找到后,执行Build.bat。完成后,可以在bin.ntx86文件夹中发现bjam.exe。最后,将bjam.exe文件拷贝到主目录下。
需要编译的Boost库
多数库不需要编译。只有部分和平台相关的需要编译。
如何编译boost
打开CMD,进入boost的主目录。命令:cd [You Path]。因为,我们已经将bjam.exe拷贝到主目录下,所以可以直接使用bjam来编译指定的boost库。
可以通过bjam --help查看相关操作,下面将一些常用的参数列出,如下:
--toolset=msvc 指定编译器。borland(对应BCB)或msvc(对应VC)或gcc(对应Mingw)
--build-dir=[temporary folder name]
--stagedir=[stage folder name] 存放编译后库文件的路径,默认是stage。
--build-type=complete 编译所有版本
{
variant=debug|release 决定编译什么版本(Debug or Release?)
link=static|shared 决定使用静态库还是动态库。
threading=single|multi 决定使用单线程还是多线程库。
runtime-link=static|shared 决定是静态还是动态链接C/C++标准库。
}
--with- 只编译指定的库,如输入--with-regex就只编译regex库了。
--show-libraries 显示需要编译的库名称
例子:如果仅编译regex和filesystem。
bjam --toolset=msvc --build-dir=midfiles --stagedir=stage --build-type=complete --with-regex --with-filesystem.
编译完成之后,可以在主目录下发现多了两个文件夹midfiles(可直接删除)和stage(可以通过--stagedir=自行指定),需要的lib就在stage文件夹下了。