LNK4068警告+ LNK1112错误导致构建故障时,将环境变量preferredtoolarchitecture设置为x64'

发布于 2025-02-13 02:00:33 字数 2994 浏览 1 评论 0原文

05-Jul-2022 09:43:39           Lib:
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64_x86\Lib.exe /OUT:"..\Lib\w2012r2\vs2015\release32mt\KerberosSupport.lib" /NOLOGO /LTCG w2012r2\vs2015\release32mt\KSDialog.res
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSKeytabOptionsDialog.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSDSNConfiguration.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSKrb5API_Windows.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSUtilities.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSKinitSupport.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSAuthenticatedCredentials.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSCredentialFactory.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSCredentials.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSGSSAPIWrapper.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSLocalCredentials.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSSecurity.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSSecurityContext.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39         2>LINK : warning LNK4068: /MACHINE not specified; defaulting to X64 [C:\bamboo-agent-home\xml-data\build-dir\Drivers\DriverShared\KerberosSupport\Maintenance\10.1\Source\KerberosSupport_vs2015_NV.vcxproj]
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39         2>w2012r2\vs2015\release32mt\KSKeytabOptionsDialog.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' [C:\bamboo-agent-home\xml-data\build-dir\Drivers\DriverShared\KerberosSupport\Maintenance\10.1\Source\KerberosSupport_vs2015_NV.vcxproj]

我担心的错误如上所述;问题的要旨是,项目文件没有targetMachine< lib>下明确设置了有关配置的配置。

在更改为PreferredToolarchitecture之前,它默认为32位构建工具,我想确定在LNK4068方案中使用的默认值,

我的问题是,根据 https://learn.microsoft.com/en-us/cpp/build/reference/running-lib?view=mmsvc-170

Usually, you don't need to specify /MACHINE. LIB infers the machine type from the .obj files. However, in some circumstances, LIB can't determine the machine type and issues an error message.

该文档是错误的吗?它看起来似乎根本不使用OBJ文件,只是使用lib.exe的位置,并且使用默认值而不是错误。

另一个问题是,我可以以某种方式避免此问题,而不必更新依赖此默认值的项目文件?我可以以某种方式从调用MSBUILD的点以某种方式注入逻辑基于项目平台的值?

05-Jul-2022 09:43:39           Lib:
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64_x86\Lib.exe /OUT:"..\Lib\w2012r2\vs2015\release32mt\KerberosSupport.lib" /NOLOGO /LTCG w2012r2\vs2015\release32mt\KSDialog.res
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSKeytabOptionsDialog.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSDSNConfiguration.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSKrb5API_Windows.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSUtilities.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSKinitSupport.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSAuthenticatedCredentials.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSCredentialFactory.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSCredentials.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSGSSAPIWrapper.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSLocalCredentials.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSSecurity.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39             w2012r2\vs2015\release32mt\KSSecurityContext.obj
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39         2>LINK : warning LNK4068: /MACHINE not specified; defaulting to X64 [C:\bamboo-agent-home\xml-data\build-dir\Drivers\DriverShared\KerberosSupport\Maintenance\10.1\Source\KerberosSupport_vs2015_NV.vcxproj]
05-Jul-2022 09:43:39    
05-Jul-2022 09:43:39         2>w2012r2\vs2015\release32mt\KSKeytabOptionsDialog.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' [C:\bamboo-agent-home\xml-data\build-dir\Drivers\DriverShared\KerberosSupport\Maintenance\10.1\Source\KerberosSupport_vs2015_NV.vcxproj]

The error I'm concerned about is shown above; the gist of the issue is that the project file doesn't have TargetMachine explicitly set under <Lib> for the configuration in question.

Before we changed to set PreferredToolArchitecture, it was defaulting to the 32-bit build tools, and I guess that determines the default that gets used in the LNK4068 scenario

My question is, according to https://learn.microsoft.com/en-us/cpp/build/reference/running-lib?view=msvc-170,

Usually, you don't need to specify /MACHINE. LIB infers the machine type from the .obj files. However, in some circumstances, LIB can't determine the machine type and issues an error message.

Is that documentation just wrong? It doesn't look like it looks at the obj files at all, just using the bitness of lib.exe, and it's using a default instead of erroring out.

The other question is can I somehow avoid this issue without having to update project files which were relying on this default? Could I somehow inject logic to default the value based on the project platform from the point of invoking msbuild?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文