Search code examples
gstreamerglib

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


my build env:

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

Before building gst-omx, I have successfully built gstreamer sdk 1.0 for tag 1.11.2 with target android_arm

gst-omx Build Command:

$./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

Then I got the error msg:

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,
^

This problem may be located on G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));

I have checked the glib library in cerbero build folder, 'location' reflects to &g_define_type_id_volatile.

Original definition is static volatile gsize g_define_type_id_volatile = 0; and type definitions are:

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

But I have no idea what's going on, and how to avoid this issue. Does anyone can help me? Thanks a lot!

Updated on 14 April:

I thought that it might due to the failure of identifying the correct tool chain, as configuration showing:

./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

From the locations marked by arrows, I doubted NDK tool chain cannot be recognized. So it used the native 64 bit gcc compiler as a substitution and sizeof these types cannot be matched.

Whether is my conclusion right?

If it's right, how to let gst-omx know where toolchain is? Thanks to everybody~


Solution

  • I have solved this problem myself.

    That's right, it's the tool chain's problem, but the tool chain in {ndkroot}/toolchains can not be used directly, otherwise various compiling errors would follow.

    Firstly I make my own toolchain with the tool given by 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
    

    Secondly I add new crosstool path to the env, to enable configure to find it:

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

    Finally modifying configure arguments:

    ./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
    

    Eventually, gst-omx plugin file would be generated in /home/leon/tools/cerbero/omx