简体   繁体   English

64位项目中的32位.obj

[英]32-bit .obj in 64-bit project

I have a 32-bit object file o.obj and want to use it in a project that uses a 64-bit library l.lib . 我有一个32位目标文件o.obj并想在使用64位库l.lib的项目中使用它。

To make the .lib happy, the Visual Studio configuration needs to be set to x64. 为了使.lib满意,需要将Visual Studio配置设置为x64。 However, the linker then throws an error of error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' . 但是,链接器然后抛出error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

I went through Visual Studio's linker options, but nothing jumped out. 我经历了Visual Studio的链接器选项,但没有任何问题。 Is there a way to resolve this error? 有没有办法解决此错误?

I was under the impression that any 32-bit code is also compatible with 64-bit systems, modulo libraries. 我的印象是,任何32位代码也都与64位系统模库兼容。

x86 executables (that is, object code compiled for 32-bit x86 processors) can be executed on x64 machines running 64-bit operating systems, through a special compatibility mode supported jointly by the processor and the operating system. 通过处理器和操作系统共同支持的特殊兼容模式,可以在运行64位操作系统的x64机器上执行x86可执行文件(即为32位x86处理器编译的目标代码)。 This is feasible because the x86 instruction set is a subset of the x64 instruction set. 这是可行的,因为x86指令集是x64指令集的子集。

However, many elements of the ABI differ between x86 and x64 code, notably calling conventions and pointer size. 但是,ABI的许多元素在x86和x64代码之间有所不同,特别是调用约定和指针大小。 The calling convention needs to match between the calling code and the called code, or things will screw up. 调用约定需要在调用代码和被调用代码之间匹配,否则事情会搞砸了。 Thus, there is no straightforward way to call 64-bit code from 32-bit code, or vice versa. 因此,没有直接的方法可以从32位代码中调用64位代码,反之亦然。

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

相关问题 Visual Studio:如何为包含32位和64位平台的项目设置Qt? - Visual Studio: How to setup Qt for a project that contains both 32-bit and 64-bit platforms? Visual Studio - 在64位项目中编译32位代码 - Visual Studio - Compiling 32-bit code inside 64-bit project Visual Studio VSTO 32 位和 64 位版本 - Visual Studio VSTO 32-bit and 64-bit builds 将 32 位 Outlook 加载项重建为 64 位 - rebuilding a 32-bit Outlook add-in as 64-bit 尝试在32位Windows上运行64位测试 - Trying to run 64-bit tests on 32-bit windows 在Visual Studio中,如何同时构建32位和64位版本的C ++项目? - In Visual Studio, how do I build 32-bit and 64-bit versions of a C++ project simultaneously? 将32位项目升级到64位后,启动应用程序失败,错误代码0xc000007b - Launching application fails with error code 0xc000007b after upgrading 32-bit project to 64-bit 从 32 位移植到 64 位 - 有没有 -Wp64 开关的替代方案? - Porting from 32-bit to 64-bit - any alternative to -Wp64 switch? 我可以在一个Visual Studio构建中构建32位和64位MSI吗? - Can I build 32-bit and 64-bit MSI in one Visual Studio build? “无法同时分析32位和64位应用程序”错误 - “It is not possible to profile 32-bit and 64-bit applications at the same time” error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM