更新时间:2021-12-18 02:10:46
虽然 Nate 的回答 已经很不错了,我将根据要求更具体地针对 Visual Studio 2010 对其进行扩展,并包括有关在需要外部库的各种可选组件中进行编译的信息.
While Nate's answer is pretty good already, I'm going to expand on it more specifically for Visual Studio 2010 as requested, and include information on compiling in the various optional components which requires external libraries.
如果您只使用头文件库,那么您需要做的就是解压缩 boost 下载并设置环境变量.下面的说明仅为 Visual Studio 设置环境变量,而不是整个系统.请注意,您只需执行一次.
If you are using headers only libraries, then all you need to do is to unarchive the boost download and set up the environment variables. The instruction below set the environment variables for Visual Studio only, and not across the system as a whole. Note you only have to do it once.
C:oost_1_47_0
).Microsoft.Cpp..user
,然后选择Properties
打开属性页进行编辑.VC++ 目录
.Include Directories
部分以包含 boost 源文件的路径.C:oost_1_47_0
).Microsoft.Cpp.<Platform>.user
, and select Properties
to open the Property Page for edit.VC++ Directories
on the left.Include Directories
section to include the path to your boost source files.如果你想使用 boost 需要构建的部分,但没有需要外部依赖的特性,那么构建它是相当简单的.
If you want to use the part of boost that require building, but none of the features that requires external dependencies, then building it is fairly simple.
C:oost_1_47_0
).bootstrap.bat
以构建 b2.exe(以前称为 bjam).运行 b2:
C:oost_1_47_0
).bootstrap.bat
to build b2.exe (previously named bjam).Run b2:
b2 --toolset=msvc-10.0 --build-type=complete stage
;b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage
去散步/看电影或 2/....
Go for a walk / watch a movie or 2 / ....
Library Directories
部分以包含boost 库输出的路径.(上述示例和说明的默认值是 C:oost_1_47_0stagelib
.如果您想让 x86 和 x64 并排放置(例如 libx64
).Library Directories
section to include the path to your boost libraries output. (The default for the example and instructions above would be C:oost_1_47_0stagelib
. Rename and move the directory first if you want to have x86 & x64 side by side (such as to <BOOST_PATH>libx86
& <BOOST_PATH>libx64
).如果您想要可选组件,那么您还有更多工作要做.它们是:
If you want the optional components, then you have more work to do. These are:
Boost.IOStreams Bzip2 过滤器:
Boost.IOStreams Bzip2 filters:
C:zip2-1.0.6
).-sBZIP2_SOURCE="C:zip2-1.0.6"
.Boost.IOStreams Zlib 过滤器
Boost.IOStreams Zlib filters
C:zlib-1.2.5
).-sZLIB_SOURCE="C:zlib-1.2.5"
.Boost.MPI
中的文件 project-config.jam
,这是运行引导程序产生的.添加一行读取using mpi ;
(注意';'之前的空格).project-config.jam
in the directory <BOOST_PATH>
that resulted from running bootstrap. Add in a line that read using mpi ;
(note the space before the ';').Boost.Python
Boost.Python
要完全构建 32 位版本的库需要 32 位 Python,对于 64 位版本也是如此.如果出于这种原因安装了多个版本,则需要告诉 b2 在哪里可以找到特定版本以及何时使用哪个版本.一种方法是编辑目录 <BOOST_PATH>
中的文件 project-config.jam
,这是运行引导程序产生的.添加以下两行,根据您的 Python 安装路径进行调整 &版本(注意';'前的空格).
To completely built the 32-bits version of the library requires 32-bits Python, and similarly for the 64-bits version. If you have multiple versions installed for such reason, you'll need to tell b2 where to find specific version and when to use which one. One way to do that would be to edit the file project-config.jam
in the directory <BOOST_PATH>
that resulted from running bootstrap. Add in the following two lines adjusting as appropriate for your Python installation paths & versions (note the space before the ';').
使用 python : 2.6 : C:\Python\Python26\python ;
using python : 2.6 : C:\Python\Python26-x64\python : :
请注意,目前这种明确的 Python 规范会导致 MPI 构建失败.因此,如果您还要构建 MPI,则需要使用规范和不使用规范进行一些单独的构建,以构建所有内容.
Do note that such explicit Python specification currently cause MPI build to fail. So you'll need to do some separate building with and without specification to build everything if you're building MPI as well.
按照上面的第二组说明来构建提升.
Follow the second set of instructions above to build boost.
Boost.Regex ICU 支持
Boost.Regex ICU support
C:icu4c-4_8
).sourceallinone
中打开 Visual Studio 解决方案.-sICU_PATH="C:icu4c-4_8"
.C:icu4c-4_8
).<ICU_PATH>sourceallinone
.-sICU_PATH="C:icu4c-4_8"
when running b2 in step 5.