【问题标题】:Building boost-python example构建 boost-python 示例
【发布时间】:2014-03-01 21:05:59
【问题描述】:

我正在运行 Ubuntu 13.10 。我安装了 libboost1.54-dev。

我对 Boost 进行了 Git 签出,并签出了“boost-1.54.0”。

我在源代码中将目录更改为 boost/libs/python/example/tutorial。

我跑了“bjam”。我明白了:

$ bjam
Unable to load Boost.Build: could not find build system.
---------------------------------------------------------
/home/dustin/build/boost/libs/python/example/boost-build.jam attempted to load the build system by invoking

   'boost-build ../../../tools/build/v2 ;'

but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching /home/dustin/build/boost/libs/python/example/../../../tools/build/v2, /usr/share/boost-build).

Please consult the documentation at 'http://www.boost.org'.

示例目录中只有三个文件:

-rw-r--r-- 1 dustin dustin  484 Mar  1 12:59 hello.cpp
-rwxr-xr-x 1 dustin dustin  275 Mar  1 12:59 hello.py
-rw-r--r-- 1 dustin dustin 1445 Mar  1 15:43 Jamroot

方向说应该就是这么简单:http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/python/hello.html

strace的最后几行是:

openat(AT_FDCWD, "/home/dustin/build/boost/libs/python/example/tutorial", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/home/dustin/build/boost/libs/python/example", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/share/boost-build", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/home/dustin/build/boost/libs/python/example/boost-build.jam", O_RDONLY) = 3

为什么要寻找 boost-build.jam?我错过了什么?

【问题讨论】:

    标签: c++ boost boost-python jam


    【解决方案1】:

    您可以创建自己的 boost-build.jam。对于快速入门示例(已损坏),只需在其中创建一个名为 boost-build.jam 的文件,并确保它指向 src 目录。这里讨论http://lists.boost.org/boost-build/2014/11/27738.php

    # Edit this path to point at the tools/build/v2 subdirectory of your
    # Boost installation.  Absolute paths work, too.
    boost-build ../../../../tools/build/src ;
    

    【讨论】:

      【解决方案2】:

      本质上,bjam 是一个解释器,而 Boost.Build 是一个用 bjam 文件编写的构建系统。当 bjam 启动时,它将尝试查找 Boost.Build 的 jam 文件。在这种情况下,bjam 尝试相对于教程定位boost-build.jam,并在它丢失时出错。要构建教程,可以:

      • 验证 boost/tools/build 子模块已从 boost git 存储库中初始化。 Boost.Python 有其他依赖项,因此初始化所有子模块可能更容易。这将允许从 libboost1.54-dev 包安装的 bjam 解释器从存储库中找到 Boost.Build,并构建教程及其依赖项。
      • 针对打包的库进行构建:

        • 安装libboost1.54 包。这将安装 Boost.Python 共享库及其依赖项。
        • 修改教程的 Jamroot 文件。它不应再尝试使用 boost 项目,而应明确列出 Boost.Python 共享库路径:

          -# Specify the path to the Boost project.  If you move this project,
          -# adjust this path to refer to the Boost root directory.
          -use-project boost
          -  : ../../../.. ;
          -
           # Set up the project-wide requirements that everything uses the
          -# boost_python library from the project whose global ID is
          -# /boost/python.
          +# boost_python library.
           project
          -  : requirements <library>/boost/python//boost_python ;
          +  : requirements <library>/usr/lib/libboost_python-py27.so ;
          

          库路径和名称可能需要根据 libboost-python1.54-dev 安装 Boost.Python 库的位置进行更改。

        • BOOST_BUILD_PATH 环境变量设置为/usr/share/boost-build/kernel 或安装libboost1.54-dev 包的任何位置boost-build.jam

      【讨论】:

      • 我正在 Archlinux 中尝试相同的任务(做 python 教程),我遇到了类似的问题。第二种方法(针对打包库构建)改善了这种情况,但我仍然遇到问题。我的 boost-build.jam 文件位于 /usr/local/share/boost-build/src/kernel/ 中,我相应地修改了环境路径。但是 bjam 报告了一个递归问题:/usr/local/share/boost-build/src/build/targets.jam:589: in start-building from module targets error: Recursion in main target references
      • 忘记我之前的评论。我在修改后的 Jamroot 文件的末尾遗漏了一个分号。这足以引发递归问题。一切都适用于您的(第二个)解决方案(以及结束分号!)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      相关资源
      最近更新 更多