【问题标题】:Cross Compile Boost library for PowerPC architecture用于 PowerPC 架构的交叉编译 Boost 库
【发布时间】:2013-02-20 07:59:54
【问题描述】:

我正在尝试为 PowerPC 架构交叉编译 Boost 库(线程、系统)。我按照以下步骤操作,但遇到了问题。

我运行一个 shell 脚本来设置我的工具链。编译器 ppc_4xx-g++ 在 shell 中可见。

后续步骤:

  1. 添加行“使用 gcc : power : ppc_4xx-g++ ;”到文件 user-config.jam
  2. 在根目录中运行 ./bootstrap.sh --prefix=BoostPowerPC。
  3. 运行 ./b2 install --build-dir=BoostPowerPC 工具集=gcc-power --with-thread --with-system 阶段

结果:创建了所有目录但编译失败。我无法附上错误日志(请将您的电子邮件发送给我,以便我可以在需要时将错误日志发送给您)。下面是错误日志的快照。

Component configuration:

- atomic                   : not building
- chrono                   : not building
- context                  : not building
- date_time                : not building
- exception                : not building
- filesystem               : not building
- graph                    : not building
- graph_parallel           : not building
- iostreams                : not building
- locale                   : not building
- math                     : not building
- mpi                      : not building
- program_options          : not building
- python                   : not building
- random                   : not building
- regex                    : not building
- serialization            : not building
- signals                  : not building
- system                   : building
- test                     : not building
- thread                   : building
- timer                    : not building
- wave                     : not building

...patience...
...found 20376 targets...
...updating 10110 targets...
common.mkdir BoostPowerPC
common.mkdir BoostPowerPC/lib
common.mkdir BoostPowerPC/boost
common.mkdir BoostPowerPC/boost/bin.v2
common.mkdir BoostPowerPC/boost/bin.v2/libs
common.mkdir BoostPowerPC/boost/bin.v2/libs/system
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release/threading-multi
gcc.compile.c++ BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release/threading-multi/error_code.o
In file included from ./boost/config/select_stdlib_config.hpp:18,
             from ./boost/config.hpp:40,
             from ./boost/system/config.hpp:13,
             from libs/system/src/error_code.cpp:18:
/opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/cstddef:50:28: error: bits/c++config.h: No such file or directory
In file included from /opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/ios:43,
             from /opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/ostream:45,
             from /opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/iterator:70,
             from ./boost/iterator.hpp:17,
             from ./boost/operators.hpp:86,
             from ./boost/system/error_code.hpp:17,
             from libs/system/src/error_code.cpp:19:
.
.
.

它抱怨找不到文件 c++config.h。但是该文件位于 /opt/ELDK/4.2/usr/include/c++/4.2.2/powerpc-linux/bits 目录中

然后我尝试在 b2 命令中使用标签“include”。但随后我收到一个错误,即找不到文件 cstddef,该文件位于目录 /opt/ELDK/4.2/usr/include/c++/4.2.2 中。我想我已经写完了包含路径。

你认为问题是什么?为什么即使文件存在,我的编译器也找不到该文件?有什么建议吗?

更新:

我使用了 -d+2 和 -q 选项,结果如下。

"ppc_4xx-g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -fPIC  -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -I"." -I"/opt/ELDK/4.2/ppc_4xx/usr/include" -c -o "BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release/threading-multi/error_code.o" "libs/system/src/error_code.cpp"

编译日志:

In file included from ./boost/config/select_stdlib_config.hpp:18,
             from ./boost/config.hpp:40,
             from ./boost/system/config.hpp:13,
             from libs/system/src/error_code.cpp:18:
/opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/cstddef:50:28: error: bits/c++config.h: No such file or directory

正如我们所见,包含所需文件的更高目录对编译器是可见的。我什至尝试使用 -L 命令并指定根目录。它仍然没有帮助。

我检查了 ppc_4xx-g++ 的编译选项和我感兴趣的 2 个选项

  1. --sysroot=:这是编译器使用的所有包含和库的根目录。

  2. -B : 使用它我们可以为编译器添加搜索路径。

我都试过了,但都没有帮助。有什么建议吗?

【问题讨论】:

    标签: c++ linux boost powerpc


    【解决方案1】:

    首先,这对于 Boost.Build 来说并不是真正的问题。这意味着通过使用最后一个命令(失败),在命令行上手动运行它,然后调整它直到它工作,它会更容易修复。

    如前所述,您应该从命令行中删除-I"/opt/ELDK/4.2/ppc_4xx/usr/include"。

    通常,编译器会自动找到自己的头文件。有两种可能的事情会影响到这一点:

    1. 您正在从实际安装编译器头文件的不同位置运行 ppc_4xx-g++。使用which ppc_4xx-g++ 找出答案。您还可以在编译器调用中添加-v,以检查它正在搜索的目录。
    2. 编译器以未知方式不正确地构建。迂腐地说,'ppc_4xx' 甚至不是有效的目标三元组,但我不知道这是否会破坏您所描述的编译方式。

    作为最后的手段,你可以试试--sysroot=/opt/ELDK/4.2/ppc_4xx/usr/bin。

    【讨论】:

    • 感谢您的 cmets,正如您所说,这不是 Boost 的问题,我找到了问题并发布了答案。
    【解决方案2】:

    您的包含路径不正确,错误清楚地表明了这一点,因为每个工具链都有自己的路径,请确保您的 STL 等包含路径已更新以指向新位置。它应该可以解决您的问题!

    【讨论】:

    • 我找到了我的问题的解决方案,请检查解决方案。感谢您的帮助。
    【解决方案3】:

    问题是由于编译器中的错误造成的。它无法递归搜索目录以查找包含文件夹。当我手动提供额外的包含路径时,它拒绝了它,说明冗余包含路径(因为它位于相同的目录结构中) - 使用 -v 选项找到了它。然后我创建了一个目录,创建了一个指向包含必要包含文件的目录的软链接,并将这个新目录包含在我的包含路径中(解决方法)。这行得通,我可以生成库。

    例如:包含文件存在于目录 abc/include/xyz/include 中,因为我已经指定了路径 abc/include,所以编译器不接受该目录。因此,我创建了一个目录别名并将其链接到 abc/include/xyz/include。然后我将 ./alias 作为包含路径之一包含在内,并且它起作用了。这是一个已知的编译器问题,在以后的版本中已修复,我认为在 4.6 中

    PS:这个想法不是我的,但在网上找到了一个类似的帖子,对我有帮助。

    【讨论】:

    • @VladimirPrus:我没有指向错误的指针,但我从post找到了解决方案
    • 谢谢。看起来像 Ubuntu 特定的错误。
    • @VladimirPrus:我不确定它是否特定于 Ubuntu,因为我没有使用 Ubuntu 并且仍然面临问题。我使用的是 linux,内核 3.0.0-14.1-build3+。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多