32位和64位可以一起工作吗? [英] Can 32 bit and 64 bit work together?

查看:27
本文介绍了32位和64位可以一起工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

64 位库可以在 32 位应用程序中工作吗?例如,我的应用程序 GUI 使用 32 位 Qt.我的业务核心是一个 64 位库.操作系统是 64 位的.他们可以一起工作吗?如何一起工作?谢谢.

Can 64 bit library work in a 32 bit application? For example, my application GUI uses 32 bit Qt. And my business core is a 64 bit library. The OS is 64 bit. Can they work together and how? Thanks.

推荐答案

简而言之:您无法将 32 位应用程序链接到 64 位库.

In short: You can't link a 32-bit app to a 64-bit library.

您可以在 64 位操作系统(至少是所有流行的 32/64 位处理器,如 AMD、Intel 和 Sparc)上使用 32 位共享库运行 32 位应用程序.但这不涉及任何库.

You can run a 32-bit application, using 32-bit shared libraries on a 64-bit OS (at least all the popular 32-/64-bit processors such as AMD, Intel and Sparc). But that doesn't involve any libraries.

更长的答案:我参与了(在郊区)一些为 x86 设计 64 位 Linux 内核的团队.有一些关于如何在技术上使这项工作成功的简短讨论(与整个项目相比,讨论持续了好几个小时).对此的简短总结是,在 64 位中,有些寄存器在 32 位中不可用.还有内存地址和寄存器中额外的 32 位的问题.假设库本身知道"它是一个 32 位兼容库,所有这些都可以解决.但是我们基本上有一个 64 位库,它被写成一个 32 位库,我们有点失去了重点.

Longer answer: I was involved (on the outskirts) of some of the teams that designed the 64-bit Linux kernel for x86. There were briefly (compared to the whole project, the discussions lasted quite a few hours) some discussion as to how you could technically make this work. The short summary of this is that in 64-bit there are registers that aren't available in 32-bit. There is also the problem of memory addresses and the extra 32-bits in registers. All of these CAN be solved supposing the library itself "knows" that it's a 32-bit compatible library. But then we basically have a 64-bit library that is written to be a 32-bit library, and we've kind of lost the point.

更多寄存器"可能不适用于某些处理器,但更大的寄存器地址/位范围肯定适用于所有 32 位和 64 位兼容处理器.而且我不知道有任何单个处理器允许 32 位代码调用 64 位共享库或静态库.除非专门编写代码来解决这个问题,否则它是行不通的,这违背了拥有通用 64 位库来支持 32 位应用程序的目的.

The "more registers" may not apply to some processors, but the bigger address/bit-range of registers definitely apply to ALL 32- and 64-bit compatible processors. And I'm not aware of any single processor that allows a 32-bit code calling a 64-bit shared library or static library. It just doesn't work unless the code is specifically written to cope with that, which defeats the purpose of having a generic 64-bit library to support 32-bit apps.

以上讨论了链接一个可执行单元,例如可执行文件、共享库或静态库.这必须是所有一点",32 或 64 - 不能混合.

The above discusses linking one executable unit, e.g. an executable file, a shared library or a static library. That has to be all "one bitness", either 32 or 64 - no mixing.

当一个进程与另一个进程通信时(例如一个 GUI 应用程序,它显示来自非 GUI 进程的状态),只要这两个进程使用相同的协议 [并且通常,IPC 不允许传递指针无论如何,因此 32 位/64 位转换不是什么大问题],您可以拥有一个 32 位进程和另一个 64 位进程.

When a process that talks to another process (e.g. a GUI app which displays status from a non-GUI process that), as long as the two processes use the same protocol [and typically, IPC doesn't allow passing of pointers anyway, so 32-/64-bit conversion isn't as big an issue], you can have one process that is 32-bit and another that is 64-bit.

这篇关于32位和64位可以一起工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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