【问题标题】:wxWidgets cross-compile - error: size of array ‘_GStaticAssertCompileTimeAssertion_0’ is negativewxWidgets 交叉编译 - 错误:数组“_GStaticAssertCompileTimeAssertion_0”的大小为负
【发布时间】:2018-04-01 15:47:23
【问题描述】:

我正在尝试在 64 位 Linux 机器上为 32 位 Linux 编译静态 wxWidgets 3.1 库。

我的配置如下:

../configure "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --host=i686-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-shared --enable-unicode
make

库开始构建,但在进行到一半时出现此错误:

In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9:0,
             from /usr/include/glib-2.0/glib/gtypes.h:32,
             from /usr/include/glib-2.0/glib/galloca.h:32,
             from /usr/include/glib-2.0/glib.h:30,
             from /usr/include/glib-2.0/gobject/gbinding.h:28,
             from /usr/include/glib-2.0/glib-object.h:23,
             from /usr/include/glib-2.0/gio/gioenums.h:28,
             from /usr/include/glib-2.0/gio/giotypes.h:28,
             from /usr/include/glib-2.0/gio/gio.h:26,
             from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
             from /usr/include/gtk-2.0/gdk/gdk.h:32,
             from /usr/include/gtk-2.0/gtk/gtk.h:32,
             from ../src/common/utilscmn.cpp:92:
/usr/include/glib-2.0/glib/gtypes.h: In function ‘gboolean 
_GLIB_CHECKED_ADD_U64(guint64*, guint64, guint64)’:
/usr/include/glib-2.0/glib/gmacros.h:142:29: error: size of array ‘_GStaticAssertCompileTimeAssertion_0’ is negative
   __attribute__((__unused__))
                         ^
/usr/include/glib-2.0/glib/gmacros.h:232:120: note: in expansion of 
macro ‘G_GNUC_UNUSED’
#define G_STATIC_ASSERT(expr) typedef char G_PASTE 
(_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] 
G_GNUC_UNUSED

^~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 
‘G_STATIC_ASSERT’
   G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
   ^~~~~~~~~~~~~~~
make: *** [Makefile:29632: corelib_utilscmn.o] Error 1

我注意到错误中提到了 glib 和 gtk-2.0。我是否缺少这些软件包的变体或者我的配置错误?我相信我的配置应该是正确的。我的configure 中是否缺少特殊的 wxWidgets 特定选项?

【问题讨论】:

  • 我认为这个答案是有缺陷的。关于--host和--build的区别肯定有一些争议。 What's the difference of ./configure option --build, --host and --target?
  • 你是对的。这是对错误的“可能重复”问题投票最多的答案。
  • 好的,我找到了我认为的问题。包含usr/lib64/glib-2.0/include/glibconfig.h 而不是/usr/lib/glib-2.0/include/glibconfig.h。我不知道为什么。我创建了一个指向 32 位标头的链接,并且不再出现错误。我认为 configure 会设置正确的标题,对吧?
  • 是的,这就是交叉编译的重点。您是否尝试过将 -m32 传递给 CFLAGS 和 CPPFLAGS? CC 和 CXX 是为编译器制作的,而不是编译器标志,所以也许这些不会被忽略。我认为你这里不需要 CC 或 CXX,configure 会根据主机/构建组合检测它需要的编译器。

标签: c++ linux cross-compiling wxwidgets glib


【解决方案1】:

在寻找答案后,似乎在 64 位 Linux 上交叉编译 32 位 Linux 的最佳方法是使用 chroot 构建环境。这显然是许多开发人员所做的。

有一些很好的说明on Github

【讨论】:

    猜你喜欢
    • 2015-05-13
    • 1970-01-01
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 2021-09-05
    • 2018-08-07
    相关资源
    最近更新 更多