gst-omx plugin build error: size of array ‘_GStaticAssertCompileTimeAssertion_1’ is negative

gst-omx plugin build error: size of array ‘_GStaticAssertCompileTimeAssertion_1’ is negative

我的构建环境:

gst-omx Version: Tag 1.11.2
OS Description: Ubuntu 16.04.2 LTS 64bit
Cerbero version: Tag 1.11.2

在构建 gst-omx 之前,我已经成功构建了带有目标 android_arm

的标签 1.11.2 的 gstreamer sdk 1.0

gst-omx 构建命令:

$./autogen.sh --host=arm-linux-androideabi --disable-gtk-doc --with-omx-target=generic --enable-static --prefix=/home/leon/tools/cerbero/omx --enable-static-plugins --disable-fatal-warnings
$make

然后我收到错误消息:

gstomxbufferpool.c: In function ‘gst_omx_memory_allocator_get_type’:
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/glib/gmacros.h:232:53: error: size of array ‘_GStaticAssertCompileTimeAssertion_1’ is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                                     ^
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/glib/gmacros.h:229:47: note: in definition of macro ‘G_PASTE_ARGS’
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                               ^
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro ‘G_PASTE’
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                            ^
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/glib/gthread.h:249:5: note: in expansion of macro ‘G_STATIC_ASSERT’
     G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));       \
     ^
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/gobject/gtype.h:1961:7: note: in expansion of macro ‘g_once_init_enter’
   if (g_once_init_enter (&g_define_type_id__volatile))  \
       ^
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/gobject/gtype.h:1732:60: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN’
#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)     _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                            ^
/home/leon/tools/cerbero/build/dist/android_arm/include/glib-2.0/gobject/gtype.h:1590:43: note: in expansion of macro ‘G_DEFINE_TYPE_EXTENDED’
#define G_DEFINE_TYPE(TN, t_n, T_P)       G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
                                           ^
gstomxbufferpool.c:97:1: note: in expansion of macro ‘G_DEFINE_TYPE’
G_DEFINE_TYPE (GstOMXMemoryAllocator, gst_omx_memory_allocator,
^

这个问题可能位于 G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));

我检查了 cerbero 构建文件夹中的 glib 库,'location' 反映到 &g_define_type_id_volatile

原始定义是static volatile gsize g_define_type_id_volatile = 0;,类型定义是:

gtypes.h(77):  typedef void* gpointer;
glibconfig.h(60): typedef unsigned int gsize;

但我不知道发生了什么,也不知道如何避免这个问题。 有没有人可以帮助我?非常感谢!

4 月 14 日更新:

我认为这可能是由于未能识别正确的工具链,如配置所示:

./configure --enable-maintainer-mode --enable-gtk-doc --host=arm-linux-androideabi --disable-gtk-doc --with-omx-target=generic --enable-static --prefix=/home/leon/tools/cerbero/omx --enable-static-plugins --disable-fatal-warnings PKG_CONFIG_PATH=/home/leon/tools/cerbero/build/dist/android_arm/lib/pkgconfig
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking target system type... arm-unknown-linux-androideabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
checking whether GID '1000' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking nano version... 0 (release)
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... (cached) yes
checking how to print strings... printf
checking for style of include used by make... GNU
checking for arm-linux-androideabi-gcc... no   <-------
checking for gcc... gcc                        <-------
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep

从箭头所指的位置,我怀疑NDK工具链无法识别。所以它使用本机 64 位 gcc 编译器作为替代,这些类型的 sizeof 无法匹配。

我的结论对吗?

如果正确,如何让gst-omx知道工具链在哪里? 感谢大家~

我自己解决了这个问题。

没错,是工具链的问题,但是{ndkroot}/toolchains中的工具链不能直接使用,否则会出现各种编译错误。

首先我使用ndk提供的工具制作了自己的工具链:

cd ~/tools/android-ndk-r13b/build/tools/
./make-standalone-toolchain.sh --platform=android-21 --install-dir=/home/leon/tools/android-toolchain --toolchain=arm-linux-androideabi-4.9

其次,我将新的 crosstool 路径添加到环境中,以启用配置来找到它:

export PATH=/home/leon/tools/android-toolchain/bin:$PATH

最终修改配置参数:

./autogen.sh --host=arm-linux-androideabi --disable-gtk-doc --with-omx-target=generic --enable-static --prefix=/home/leon/tools/cerbero/omx --enable-static-plugins --disable-fatal-warnings PKG_CONFIG_PATH=/home/leon/tools/cerbero/build/dist/android_arm/lib/pkgconfig --with-sysroot=/home/leon/tools/android-toolchain/sysroot
make & make install

最终,gst-omx 插件文件将在 /home/leon/tools/cerbero/omx

中生成