[英]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.