简体   繁体   English

提升库 - 只构建我需要的东西

[英]Boost libraries - build only what I need

I downloaded the Boost libraries and now I want to build only a few of the libraries. 我下载了Boost库,现在我只想构建一些库。 What would be the right command for this? 什么是正确的命令? Apparently the built-type=complete option gives me too much. 显然,内置类型=完整选项给了我太多。 I am using Windows XP and want to use Bjam to compile Boost and MinGW to finally use it. 我正在使用Windows XP,并希望使用Bjam编译Boost和MinGW以最终使用它。 At the moment I think I need the libraries Boost.filesystem, Boost.ProgramOptions and Boost.System. 目前我认为我需要库Boost.filesystem,Boost.ProgramOptions和Boost.System。 Another question: Where do I put the header-only libraries? 另一个问题:我在哪里放置仅限标头的库?

In step 5.2.4 of Getting Started you can instruct b2 which libraries to build: 在“ 入门”的 步骤5.2.4中 ,您可以指示b2构建哪些库:

./b2 --with-program_options --with-filesystem --with-system

Alternatively, use ./b2 --show-libraries to see a list of all libraries that are not header-only. 或者,使用./b2 --show-libraries查看不是仅标头的所有库的列表。

Following is an excerpt from the page: 以下是该页面的摘录:

In particular, to limit the amount of time spent building, you may be interested in: 特别是,为了限制建设所花费的时间,您可能会对以下内容感兴趣:

  • reviewing the list of library names with --show-libraries 使用--show-libraries查看库名列表
  • limiting which libraries get built with the --with-<library-name> or --without-<library-name> options 限制使用--with-<library-name>--without-<library-name>选项构建哪些库
  • choosing a specific build variant by adding release or debug to the command line. 通过向命令行添加发布或调试来选择特定的构建变体。

Note: b2 command depends upon boost version so use following commands as per your boost version(Also, in this case use --with-libraries=<comma-seperated-library-names> version instead of --with-<library-name> ): 注意: b2命令取决于boost版本,因此根据你的boost版本使用以下命令(另外,在这种情况下,使用--with-libraries=<comma-seperated-library-names>版本而不是--with-<library-name> ):

  • ./configure for 1.38.0 and earlier 1.38.0 ./configure 1.38.0及更早版本
  • ./bootstrap.sh for 1.39.0 onwards till 1.46.0 ./bootstrap.sh1.39.0开始直到1.46.0

These answers didn't work for me. 这些答案对我不起作用。 On Windows, this worked for me: 在Windows上,这对我有用:

b2.exe -with-LIBRARY

For example, 例如,

b2.exe -with-test

The BCP utility is a tool for extracting subsets of Boost. BCP实用程序是用于提取Boost子集的工具。 It's useful for Boost authors who want to distribute their library separately from Boost, and for Boost users who want to distribute a subset of Boost with their application. 它对于希望与Boost分开分发库的Boost作者以及希望将Boost子集与其应用程序一起分发的Boost用户非常有用。

The current version of Boost (1.50.0) uses Boost.Build. 当前版本的Boost(1.50.0)使用Boost.Build。 The new workflow for building BCP is as follows: 构建BCP的新工作流程如下:

From the root Boost directory, type: 从根Boost目录中,键入:

bootstrap.bat

Then, once Boost.Build has been built, type: 然后,一旦构建了Boost.Build,键入:

b2 tools/bcp

To extract, for example interprocess only, you could use: 要提取,例如仅进行interprocess ,您可以使用:

$ mkdir /tmp/interprocess #bcp needs this
$ bcp interprocess /tmp/interprocess

This copies interprocess and its dependencies to /tmp/interprocess . 这会将进程间及其依赖项复制到/tmp/interprocess

I had the same problem. 我有同样的问题。 But I found a way to create the necessary files. 但我发现了一种创建必要文件的方法。

Steps to follow: 要遵循的步骤:

  1. If you have Microsoft Visual Studio 2010 then open the Microsoft Visual Studio command prompt (2010) in administrator mode. 如果您有Microsoft Visual Studio 2010,则以管理员模式打开Microsoft Visual Studio命令提示符(2010)。
  2. First enter the code: 首先输入代码:

     bootstrap.bat 
  3. Then enter the following code to generate lib files: 然后输入以下代码以生成lib文件:

     b2.exe link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-system --toolset=msvc-10.0 define=BOOST_USE_WINAPI_VERSION=0x0500 
  4. Library files will be created in stage folder. 库文件将在stage文件夹中创建。

My last build attempt for the Boost 1.55 libraries was a dissappointment. 我对Boost 1.55库的最后一次构建尝试令人失望。 All attempts to build several libraries and only them has ended up with total mess in output. 所有构建几个库的尝试都只是输出完全混乱。

BJam either tries to build everything or build only the requested, but in the "bin.v2/[long-random-path]" folders (library per directory) with crap in them which is a headache to copy only the link libraries to somethere else. BJam要么尝试构建所有内容,要么只构建所请求的内容,而是在“bin.v2 / [long-random-path]”文件夹(每个目录库)中使用垃圾,这很难将链接库复制到某个地方其他。

I have accidentally found the right way to build-and-collect only the libraries I want in one place without any other crap: 我不小心找到了正确的方法来构建和收集我想要的库在一个地方没有任何其他废话:

bjam ... --with-[library1] --with-[library2] stage bjam ... --with- [library1] --with- [library2] stage

  • the "stage" option is required to build and collect libraries in one folder: /stage/lib 在一个文件夹中构建和收集库需要“stage”选项:/ stage / lib
  • the "--with-[library]" option is required to build only the library you want. 只需要构建所需的库,需要“--with- [library]”选项。

An additional note for anyone who sees the error message: "error: wrong library name '<name of library>' in the --with-<library> option." 对于看到错误消息的任何人的附加说明: "error: wrong library name '<name of library>' in the --with-<library> option." .

If you try to be clever, as I did, and only extract the boost sub-directory of the download onto your system to minimise space, b2 will not be able to find the source code and build options for those libraries that are not header-only. 如果你像我一样聪明,并且只将下载的boost子目录提取到你的系统上以最小化空间, b2将无法找到那些不是标题库的源代码和构建选项 -只要。 Ie you need the lib sub-directory too (and tools ). 即你也需要lib子目录(和tools )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM