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

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

问题描述

在 64 位主机上,我尝试使用 -m32 选项构建共享库.这些库是否可以与常规 64 位库链接?

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.so32_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?

推荐答案

无法将 32 位应用程序链接到 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:跳过不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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