VS安装Boost库

来源:互联网 发布:金山pdf是什么软件 编辑:程序博客网 时间:2024/06/11 01:37

1. 下载Boost库

2. 解压boost源码包

解压到`D:\boost_1_55_0`目录下

3. 生成bjam

打开VS2008->VS TOOLS->VS命令提示,在VS命令行中进入D:\boost_1_55_0目录。
执行bootstrap.bat,在当前目录下生成bjam.exe。

4. 编译Boost库

在VS命令行中输入如下bjam命令,编译所有的库。

bjam toolset=msvc-9.0 variant=debug,release threading=multi link=static

bjam参数

选项 描述 –build-dir= 编译的临时文件会放在builddir里(这样比较好管理,编译完就可以把它删除了) –stagedir= 存放编译后库文件的路径,默认是stage –build-type=complete 编译所有版本,不然只会编译一小部分版本(确切地说是相当于:variant=release, threading=multi;link=shared|static;runtime-link=shared) variant=debug|release 决定编译什么版本(Debug or Release?) link=static|shared 决定使用静态库还是动态库。 threading=single|multi 决定使用单线程还是多线程库。 runtime-link=static|shared 决定是静态还是动态链接C/C++标准库。 –with- 只编译指定的库,如输入–with-regex就只编译regex库了。 –show-libraries 显示需要编译的库名称

需要编译的库有:

date-time, filesystem, graph,graph_parallel, iostreams, math, mpi, program_options,python,random, regex, serialization, signals, system, test, thread, wave.
其他的库不需单独编译,可以直接使用。比如asio,如果试图单独编译asio库,bjam --with-asio,则会报wrong library name错误。
如果只需要编译regex、thread库,在bjam命令中指定相应的库:

bjam toolset=msvc-9.0 variant=debug,release threading=multi link=static --with-regex --with-thread

如果不需要编译python库,在bjam命令中指定:

bjam toolset=msvc-9.0 variant=debug,release threading=multi link=static --with-regex --without-python

5. 配置VS

Tools -> Options -> Projects and Solutions -> VC++ Directories
Library files中,增加D:\boost_1_55_0\bin\vc9\lib
Include files中,增加D:\boost_1_55_0
其中,Library的目录就是前面编译产生的那些库文件保存到的位置

1 0
原创粉丝点击