linux - 交叉编译 gstreamer 失败 : x86-64 -> ARMv6 32-bit

标签 linux arm cross-compiling gstreamer

我正在尝试在 x86_64 (linux) 系统上为 RPi 1 构建一个项目。我有一个可用的工具链 - 我已经构建了一个小程序并在 RPi 上运行它(“Hello World”)。

我正在尝试构建的项目是 gstreamer .

配置脚本中,我添加了适当的--host=,它找到了所有正确的工具并成功完成。但是,当我做这个项目时, 我收到以下错误:

    In file included from gsttracerutils.h:30:0,
                 from gst_private.h:68,
                 from gst.c:96:
../gst/gstutils.h: In function '__gst_slow_read64_be':
../gst/gstutils.h:111:61: error: left shift count >= width of type [-Werror=shift-count-overflow]
     (((guint##__size) (((const guint8 *) (__data))[__idx])) << (__shift))
                                                             ^
../gst/gstutils.h:164:36: note: in expansion of macro '_GST_GET'
 #define _GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \
                                    ^
../gst/gstutils.h:184:10: note: in expansion of macro '_GST_READ_UINT64_BE'
   return _GST_READ_UINT64_BE (data);
          ^

似乎(至少对我而言)编译器在提示 32 位 cpu 上的 64 位类型(这是正确的)。

这是工具链编译器的问题吗?还是别的?

我最初在 rpi 本身上(成功地)构建了 gstreamer。但由于这花了很长时间,而且我需要能够重新制作应用程序,所以我想在一个快速的系统上构建它。

澄清一下: 我使用的构建工具链是 crosstool-ng。 我将配置命令运行为:

./configure --disable-gtk-doc --disable-examples --disable-benchmarks --disable-gtk-doc-html --host=armv6-rpi-linux-gnueabihf

以及来自配置日志 (config.log):

## ----------- ##
## Core tests. ##
## ----------- ##

configure:3217: checking build system type
configure:3231: result: x86_64-unknown-linux-gnu
configure:3251: checking host system type
configure:3264: result: armv6-rpi-linux-gnueabihf
configure:3284: checking target system type
configure:3297: result: armv6-rpi-linux-gnueabihf
configure:3343: checking for a BSD-compatible install
configure:3411: result: /usr/bin/install -c
configure:3422: checking whether build environment is sane
configure:3477: result: yes
configure:3536: checking for armv6-rpi-linux-gnueabihf-strip
configure:3552: found /nas/temp/build/rpi/tc/x-tools/armv6-rpi-linux-gnueabihf/bin/armv6-rpi-linux-gnueabihf-strip
configure:3563: result: armv6-rpi-linux-gnueabihf-strip

这表明构建系统是 x86_64,主机和目标是 armv6(...)。

如上所示,错误与处理 64 位数据的宏有关。

我可以采用这个相同的项目树,运行 autogen.sh、configure.sh,然后在 rpi-1 本身上进行构建(使用 gcc 工具的 pignus 版本 - pignus 是专门针对 rpi-1 的 fedora 23 spin) ,它完全成功构建。我还在 x86_64 系统上并为 x86_64 系统构建了这个项目,这也很成功。

并且,如开头所述,我使用相同的工具链构建了一个简单的程序——“Hello World”程序——它在 x86_64 系统上编译和链接成功,然后在 rpi 上成功运行。

所以,我的问题是:这可能是交叉编译器工具链的问题/错误,还是项目源代码中的问题?关于去哪里看或尝试什么有什么建议吗?

TIA

最佳答案

从拆箱those macros ,编译器特别提示的是,将 guint64 类型的值左移 56 位会使类型溢出,因此未定义。

现在,这对我来说意味着你正在获取你的主机 glibconfig.h,其中 guint64 必须是 unsigned long 的 typedef ,即该机器上的 64 位类型,但一旦将其提供给 32 位 ARM 编译器,就会变成 32 位。在 Pi 本身上,您可能有一个适当配置的 glibconfig.h,其中 guint64unsigned long long 的类型定义,因此构建 native 工作。

您需要将构建指向 Pi 的 GLib header 和库,而不是主机的(这个编译错误几乎肯定只是在交叉链接器找到 x86 库并拒绝它们时延迟最终链接失败)。我自己没有使用 GStreamer 的经验,所以我不能确切地说出该怎么做,但根据 this mailing list post我发现,正确的方法似乎涉及覆盖 PKG_CONFIG_PATH。

关于linux - 交叉编译 gstreamer 失败 : x86-64 -> ARMv6 32-bit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38923486/

相关文章:

c++ - 如何在 C++ 汇编代码中查找 VPTR?

linux - 在 bash 中,如何为后台进程命令输入密码?

linux - 从 Rundeck (Linux) 运行命令的问题

c - Visual Studio 相当于 Arm #pragma anon_unions

c++ - 使用 GCC 或/和 IAR 编译时如何禁用 double 学?

regex - 从标准输出获取匹配后的文本

Android:为 ARMv7 外部构建 kexec - 错误包括 'expected ' =', ' ,', ' ;', ' asm' 或 '__attribute__' token 之前的 '*'

java - 在 1.6 VM 上运行的 "-target 1.5"生成的 Java 类文件的性能影响?

Android NDK 工具链内部编译器错误

debian - 如何为 ARM Raspberry Pi 交叉编译 debian 包