c++ - 如何使用 BCP 提取可以构建的 Boost 子集?

标签 c++ linux boost build

我正在尝试使用 bcp tool在 Boost 中提取标题/库的子集以在我的项目中使用。

  • 操作系统:Linux Ubuntu 12.04 LTS x64
  • Boost 版本:1.56.0,下载为 来自 boost.org 的源代码

我也想使用 bcp 提供的自定义命名空间,但需要构建生成的代码,这并不像它应该的那样简单。

我本以为很简单

./dist/bin/bcp --namespace=myboost build filesystem ../myboost

生成一组可以构建“文件系统”库的文件就足够了,但似乎还有不断出现的额外问题。

我在网络上阅读了尽可能多的相关帖子,但没有一个提出有效的解决方案。

我遵循的步骤和相应的错误消息在下面详述。


解压 boost 1.56.0 tarball 后,我做了以下操作:

./bootstrap.sh
./b2 tools/bcp
mkdir ../myboost
./dist/bin/bcp --namespace=myboost build filesystem ../myboost

复制到 ../myboost 的文件不包括 bootstrap.sh、b2、bjam 或其他 *.jam 文件,这些似乎是“构建”目标应该包括的内容,对吧?

其他来源(包括 stackoverflow 帖子)建议从原始 boost 位置复制这些文件:

cp bootstrap.sh boost-build.jam boostcpp.jam ../myboost
cd ../myboost
./bootstrap.sh

然后构建 b2 和 bjam ok。

当运行 b2 时,东西倒了:

./b2

/work/approved-osslibs/boost/boost-1.56.0/myboost/tools/build/src/build /project.jam:262: in find-jamfile from module project
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory 'tools/inspect/build'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
<error backtrace lines snipped>

所以这对我来说意味着“构建”工具依赖于“检查”,所以我们回去复制它:

cd ../boost_1_56_0
./dist/bin/bcp --namespace=myboost inspect ../myboost
cd ../myboost
./b2

导致错误:

/work/myboost/tools/build/src/build/project.jam:262: in find-jamfile from module project
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory 'libs/wave/tool/build'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
<error backtrace lines snipped>

所以这意味着“构建”也取决于 wave...

cd ../boost_1_56_0
./dist/bin/bcp --namespace=myboost wave ../myboost
cd ../myboost
./b2

此时我遇到了这个错误:

/work/myboost/tools/build/src/build/targets.jam:397: in find-really
*** argument error
* rule project.is-registered-id ( id )
* called with: (  )
* missing argument id
/work/myboost/tools/build/src/build/project.jam:600:see definition of rule 'project.is-registered-id' being called
<error backtrace lines snipped>

我发现这个特定错误与 this ticket 中引用的 boost 文件系统库有关但这应该已经修复,所以我没想到会在最新版本的 Boost 1.56.0 中看到它。

这是怎么回事?

为什么 bcp 不能只为一个 boost 库创建一个可执行的构建系统?

为什么构建依赖于 inspect 和 wave,它们向提取的“myboost”添加了比应有的更多的 header ?

在此问题上的任何帮助将不胜感激。

最佳答案

我今天尝试使用 Boost 1.64(我在 MS Windows 下使用 MSVC 2010 编译)执行此操作时遇到了一些问题。顺便说一句,谢谢你给我指明了正确的方向。

  • 从原始 Boost 目录中的 bootstrap.batb2 -j 8 tools\bcp 开始。 (在这里以及下面,将 8 替换为要同时运行的作业数。)
  • 当运行 .\dist\bin\bcp 时,我发现我必须包含 tools\build\srclibs\config\checks\architecture 在我的命令行上,以便以后的构建工作。
  • 我还必须将 bootstrap.batboost-build.jamboostcpp.jam 复制到我复制的 boost 目录中。
  • 我不知道为什么,但我不得不重命名我原来的 Boost 目录(即运行 bcp 的目录),否则构建会以某种方式最终回到那里。<

在那之后,切换到我复制的 boost 目录并运行 bootstrap.bat 允许我构建我的 Boost 精简版,并更改了顶级命名空间。

b2 -j 8 toolset=msvc-10.0 threading=multi link=shared address-model=32 variant=debug

b2 -j 8 toolset=msvc-10.0 threading=multi link=shared address-model=32 variant=release

移动阶段\lib lib32-msvc-10.0

关于c++ - 如何使用 BCP 提取可以构建的 Boost 子集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26132227/

相关文章:

c++ - 我需要一个 Mac 上的 C++ 函数,比如 std::cin 但有超时

c++ - 为什么 void* 在 C++ 中被认为是不安全的?

c++ - 错误 "requested alignment is not an integer constant"

linux - 无法在 Linux 上运行 VSCode

linux - 广播 socket

boost - 是否在 boost multi_index 中修改不同的字段值线程安全

c++ - 创建 RGB 值为 73,95,105 的背景

html - AMP : why are files with . amp.html 扩展未在 Linux 主机上显示?

c++ - boost asio无法识别计时器对象

c++ - 相当于Boost.Format的C++ 11