简体   繁体   English

64位Ubuntu 16.04上的32位编译失败

[英]32 bit compilation failing on 64 bit Ubuntu 16.04

I have an application that requires the use of glib and a 32 bit library supplied by a third party. 我有一个应用程序需要使用glib和第三方提供的32位库。

When I compile on 32 bit Ubuntu the application builds and runs successfully. 当我在32位Ubuntu上编译时,应用程序构建并成功运行。 However when I try the same on 64 bit Ubuntu it fails to build because of the following error: 但是,当我在64位Ubuntu上尝试相同时,由于以下错误,它无法构建:

/usr/include/glib-2.0/glib/gtypes.h: In function ‘_GLIB_CHECKED_ADD_U64’:
/usr/include/glib-2.0/glib/gmacros.h:217:53: error: size of array ‘_GStaticAssertCompileTimeAssertion_0’ is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                                 ^
/usr/include/glib-2.0/glib/gmacros.h:214:47: note: in definition of macro ‘G_PASTE_ARGS’
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                           ^
/usr/include/glib-2.0/glib/gmacros.h:217: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
                                        ^
/usr/include/glib-2.0/glib/gtypes.h:422:3: note: in expansion of macro ‘G_STATIC_ASSERT’
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
^

Note: I have gcc-multilib and g++-multilib. 注意:我有gcc-multilib和g ++ - multilib。 I also tried changing the defines inside /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h from 8 to 4 with no success. 我也尝试将/usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h的定义从8更改为4,但没有成功。 I also tried installing libglib2.0-dev:i686 but pkg config in cmake can not find glib. 我也试过安装libglib2.0-dev:i686但是cmake中的pkg config找不到glib。 I am also using the appropriate -m32 flags for C, CXX and LD 我也在为C,CXX和LD使用适当的-m32标志

Any help with this issue would be greatly appreciated. 任何有关此问题的帮助将不胜感激。

No idea why glib wouldn't try to use int64_t instead of duplicating that. 不知道为什么glib不会尝试使用int64_t而不是重复它。 Seems silly to me. 对我来说似乎很傻。 Maybe they do this on purpose to increase the chance of breaking if you do what you did, and try to compile 32-bit code using a 64-bit glib install. 也许他们是故意这样做的,如果你做了你做的事情就增加破解的机会,并尝试使用64位glib安装编译32位代码。

To compile 32-bit apps, you need 32-bit library object files ( .so ). 要编译32位应用程序,您需要32位库对象文件( .so )。 They will come with a glibconfig.h that has appropriate typedefs for -m32 . 它们将带有一个glibconfig.h ,它具有适用于-m32 typedef。

Installing libglib2.0-dev:i686 should be the right approach. 安装libglib2.0-dev:i686应该是正确的方法。 I assume you eventually got that sorted out, so the app you're building finds the -I include paths and -L library paths for it. 我假设您最终解决了这个问题,因此您正在构建的应用程序会找到-I包含路径和-L库路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM