GCC -m32标志:/ usr / bin / ld:skipping不兼容 [英] GCC -m32 flag: /usr/bin/ld: skipping incompatible

查看:513
本文介绍了GCC -m32标志:/ usr / bin / ld:skipping不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在64位主机上,我试图用 -m32 选项构建共享库。

On 64 bit host I am trying to build shared libraries with -m32 option. Is it possible for these libraries to be linked with regular 64 bit libraries?

我正在做这样的事情:

g++ -m32 -shared source.cpp -l 64_bit_library.so -o 32_bit_library.so

并得到如下错误消息:

/usr/bin/ld: skipping incompatible 64_bit_library.so

所以我的问题是: 64_bit_library.so 32_bit_library.so 应该在64位主机上编译,以使 32_bit_library.so 64_bit_library.so

So my question is: how 64_bit_library.so and 32_bit_library.so should be compiled on 64 bit host, to make it possible for 32_bit_library.so to be linked against 64_bit_library.so?

推荐答案

链接位应用程序与64位库相反,反之亦然。问题是指针和类型通常不能在它们之间传递。通常,解决方法是生成其他大小的子进程,并使用IPC与该进程通信。

It's not possible to link 32 bit applications against 64 bit libraries and vice versa. The problem is that pointers and types in general can't be passed between them. Normally the workaround is to spawn a child process of the other size and use IPC to communicate with that process.

以这种方式考虑:如果我有一个C平凡函数:

Think about it this way: If I have a C trivial function:

extern void foo(void*); 

如果它在64位库中,我试着从32位库中调用它,的指针来自?

If it's in a 64bit library and I try and call it from a 32bit library where does the other half of the pointer come from?

相反,如果它在一个32位的库中,我从一个64位的应用程序调用它将对指针的另一半发生什么,我会有失去打电话吗?

Conversely if it's in a 32bit library and I call it from a 64bit application what happens to the other half of the pointer which I would have to lose to call it?

这篇关于GCC -m32标志:/ usr / bin / ld:skipping不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆