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

Til*_*l B 40 c++ boost

我下载了Boost库,现在我只想构建一些库.什么是正确的命令?显然,内置类型=完整选项给了我太多.我正在使用Windows XP,并希望使用Bjam编译Boost和MinGW以最终使用它.目前我认为我需要库Boost.filesystem,Boost.ProgramOptions和Boost.System.另一个问题:我在哪里放置仅限标头的库?

Sam*_*ler 62

在" 入门"的步骤5.2.4中,您可以指示构建哪些库:b2

./b2 --with-program_options --with-filesystem --with-system
Run Code Online (Sandbox Code Playgroud)

或者,用于./b2 --show-libraries查看不是标题的所有库的列表.

以下是该页面的摘录:

特别是,为了限制建设所花费的时间,您可能会对以下内容感兴趣:

  • 使用查看库名称列表 --show-libraries
  • 限制使用--with-<library-name>--without-<library-name>选项构建哪些库
  • 通过向命令行添加发布或调试来选择特定的构建变体.

注意: b2命令取决于boost版本,因此请根据您的boost版本使用以下命令(此外,在这种情况下使用--with-libraries=<comma-seperated-library-names>版本而不是--with-<library-name>):

  • ./configure为了1.38.0和更早
  • ./bootstrap.sh对于1.39.0起直到1.46.0

  • 在最近的Boost中,用`b2`替换`bootstrap`. (3认同)

Coo*_*kie 13

这些答案对我不起作用.在Windows上,这对我有用:

b2.exe -with-LIBRARY
Run Code Online (Sandbox Code Playgroud)

例如,

b2.exe -with-test
Run Code Online (Sandbox Code Playgroud)

  • 至少在当前版本(1.57)中需要双短划线,例如`b2.exe --with-filesystem` (4认同)

小智 7

BCP实用程序是用于提取的Boost子集的工具.它对于希望与Boost分开分发库的Boost作者以及希望将Boost子集与其应用程序一起分发的Boost用户非常有用.

当前版本的Boost(1.50.0)使用Boost.Build.构建BCP的新工作流程如下:

从根Boost目录中,键入:

bootstrap.bat
Run Code Online (Sandbox Code Playgroud)

然后,一旦构建了Boost.Build,键入:

b2 tools/bcp
Run Code Online (Sandbox Code Playgroud)

例如interprocess,要提取,您可以使用:

$ mkdir /tmp/interprocess #bcp needs this
$ bcp interprocess /tmp/interprocess
Run Code Online (Sandbox Code Playgroud)

这会将进程间及其依赖项复制到/tmp/interprocess.


Aru*_*san 6

我有同样的问题.但我发现了一种创建必要文件的方法.

要遵循的步骤:

  1. 如果您有Microsoft Visual Studio 2010,则以管理员模式打开Microsoft Visual Studio命令提示符(2010).
  2. 首先输入代码:

    bootstrap.bat
    
    Run Code Online (Sandbox Code Playgroud)
  3. 然后输入以下代码以生成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
    
    Run Code Online (Sandbox Code Playgroud)
  4. 库文件将在stage文件夹中创建.