致命错误 LNK1112:模块机器类型“x64”与目标机器类型“X86”冲突

发布于 2024-09-16 08:32:22 字数 261 浏览 7 评论 0 原文

我正在使用 CUDA(VC++、Visual studio 2008sp1)来调试 FEM 程序。由于cuda的不足,该程序只能运行在Win32平台上。我认为链接的库文件都是在x86平台上编译的,但是当我编译它时,出现错误消息

致命错误 LNK1112:模块机器类型“x64”与目标机器类型“X86”冲突。

我尝试过将平台转换为 x64,但没有成功。请告诉我:什么是“模块机器类型”,什么是“目标机器类型”?我怎样才能克服它?

I'm using CUDA (VC++, Visual studio 2008sp1) to debug a FEM program. The program can only run on a Win32 platform, for the insufficiency of cuda. I think the library files linked are all compiled on the x86 platform, but when I compile it, I get the error message

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'.

I have tried to convert the platform to x64, but it didn't work. Please tell me: what is "module machine type" and what is "target machine type"? How can I overcome it?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(29

三人与歌 2024-09-23 08:32:22

我写了一篇关于此的博客条目,因为我遇到了这个令人抓狂的问题,最终使我的系统恢复正常工作。

这些是要检查的内容,按以下顺序:

  1. 检查链接器设置中的属性选项:属性 >配置属性>链接器>高级>目标机。如果您的目标是 64 位构建,请选择 MachineX64;如果您要进行 32 位构建,请选择 MachineX86。

  2. 选择构建> Visual Studio 中主菜单中的配置管理器。确保您的项目指定了正确的平台。 IDE 可以设置为构建 x64,但解决方案中的单个项目可以设置为目标 win32。所以,是的,视觉工作室留下了很多绳子来吊死自己,但这就是生活。

  3. 检查您的库文件是否确实属于目标平台类型。可以通过使用 Visual Studio VC\bin 目录中的 dumpbin.exe 来使用它。使用 -headers 选项转储所有函数。查找每个功能的机器条目。如果是 64 位版本,则应包含 x64。

  4. 在 Visual Studio 中,选择“工具”>“工具”>主菜单中的选项。选择项目和解决方案 > VC++ 目录。从平台下拉列表中选择 x64。确保第一个条目是:$(VCInstallDir)\bin\x86_amd64,后跟 $(VCInstallDir)\bin

一旦我完成了第四步,一切就对我来说再次起作用了。问题是我在所有想要编译 64 位目标的项目中都遇到了这个问题。

I wrote a blog entry about this, as I encountered this maddening problem, and finally yanked my system back into working order.

These are the things to check, in this order:

  1. Check your properties options in your linker settings at: Properties > Configuration Properties > Linker > Advanced > Target Machine. Select MachineX64 if you are targeting a 64 bit build, or MachineX86 if you are making a 32 bit build.

  2. Select Build > Configuration Manager from the main menu in visual studio. Make sure your project has the correct platform specified. It is possible for the IDE to be set to build x64 but an individual project in the solution can be set to target win32. So yeah, visual studio leaves a lot of rope to hang yourself, but that's life.

  3. Check your library files that they really are of the type of platform are targeting. This can be used by using dumpbin.exe which is in your visual studio VC\bin directory. use the -headers option to dump all your functions. Look for the machine entry for each function. it should include x64 if it's a 64 bit build.

  4. In visual studio, select Tools > Options from the main menu. select Projects and Solutions > VC++ Directories. Select x64 from the Platform dropdown. Make sure that the first entry is: $(VCInstallDir)\bin\x86_amd64 followed by $(VCInstallDir)\bin.

Once I did step 4 everything worked again for me. The thing was I was encountering this problem on all my projects where I wanted to compile towards a 64 bit target.

情域 2024-09-23 08:32:22

除了 C Johnson 列表之外,我还要添加以下几点:

在 Visual Studio 中检查项目的以下选项:
项目属性 ->配置属性->链接器->命令行

“附加选项” 不应包含 /machine:X86

我有这样的密钥,由 CMake 输出生成: CMake 生成了 x86 项目,然后我通过 Visual Studio 2010 中的配置管理器 添加了 x64 平台 - 除了链接器命令之外,一切都为新平台创建得很好行,单独指定 /machine:X86

In addition to C Johnson list I would add the following point:

Check following option for the project in the Visual Studio:
Project Properties -> Configuration Properties -> Linker -> Command line.

"Additional Options" should NOT contain /machine:X86

I have such key, generated by CMake output: CMake generated x86 project, then I added x64 platform via Configuration Manager in Visual Studio 2010 - everything was created fine for the new platform except that the linker command line, specified /machine:X86 separately.

我不会写诗 2024-09-23 08:32:22

当我尝试将 X64 构建添加到从 VS2003 转换的项目时,我在 VS2008 中遇到了同样的问题。

我查看了在 Google 上搜索此错误时发现的所有内容(目标计算机、VC++Directories、DUMPBIN...),一切看起来都正常。

最后我创建了一个新的测试项目并做了相同的更改,它似乎有效。

在 vcproj 文件之间进行比较揭示了问题......

我转换的项目将 /MACHINE:i386 设置为链接器 -> 命令行下的附加选项集。因此,设置了两个 /MACHINE 选项(x64 和 i386),并且优先使用附加选项。

删除它并在链接器 - >高级 - >目标机器下正确设置它使问题消失。

I experienced the same problem in VS2008 when I tried to add a X64 build to a project converted from VS2003.

I looked at everything found when searching for this error on Google (Target machine, VC++Directories, DUMPBIN....) and everything looked OK.

Finally I created a new test project and did the same changes and it seemed to work.

Doing a diff between the vcproj files revealed the problem....

My converted project had /MACHINE:i386 set as additional option set under Linker->Command Line. Thus there was two /MACHINE options set (both x64 and i386) and the additional one took preference.

Removing this and setting it properly under Linker->Advanced->Target Machine made the problem disappeared.

贩梦商人 2024-09-23 08:32:22

所有项目设置看起来都很完美,但我仍然遇到错误。查看 .vcxproj 文件并搜索“x86”揭示了问题:

<Lib>
  <AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
</Lib>

对所有出现的情况(十个单独的文件设置)进行快速搜索/替换修复了问题。

All project settings seemed perfect, but I still got the error. Looking into the .vcxproj file and searching for "x86" revealed the problem:

<Lib>
  <AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
</Lib>

A quick search/replace for all occurrances (ten individual file settings) fixed the problem.

攀登最高峰 2024-09-23 08:32:22

当您链接 x86(这是目标机器类型)时,您可能有一个针对 x64(这是模块机器类型)的 .OBJ 或 .LIB 文件。

对 .OBJ 文件使用 DUMPBIN /HEADERS 并检查 FILE HEADER VALUES 块中的机器条目。

You probably have one .OBJ or .LIB file that's targeted for x64 (that's the module machine type) while you're linking for x86 (that's the target machine type).

Use DUMPBIN /HEADERS on your .OBJ files and check for the machine entry in the FILE HEADER VALUES block.

硬不硬你别怂 2024-09-23 08:32:22

由于该问题是由于编译和目标机器规格(x86 & x64)的差异造成的
请按照以下步骤操作:

  1. 打开要配置的 C++ 项目。
  2. 选择“配置管理器”按钮以打开“配置管理器”对话框。
  3. 在“活动解决方案平台”下拉列表中,选择用于打开“新建解决方案平台”对话框的选项。
  4. 在类型或选择新平台下拉列表中,选择 64 位平台。

它解决了我的问题。

Since the problem is due to the difference in compilation and target machine specifications (x86 & x64)
Follow the steps below:

  1. Open the C++ project that you want to configure.
  2. Choose the Configuration Manager button to open the Configuration Manager dialog box.
  3. In the Active Solution Platform drop-down list, select the option to open the New Solution Platform dialog box.
  4. In the Type or select the new platform drop-down list, select a 64-bit platform.

It solved my problem.

同展鸳鸯锦 2024-09-23 08:32:22

在 Visual Studio 2012 +/- 中,“配置属性”.Linker.“命令行”的属性页包含一个标有“附加选项”的框。如果您正在构建 x64,请确保该框不包含 /MACHINE: I386。我的项目确实如此,并且生成了相关错误。

In Visual Studio 2012 +/-, the property page for "Configuration Properties'.Linker."Command Line" contains a box labeled "Additional Options". If you're building x64, make sure that box doesn't contain /MACHINE:I386. My projects did and it generated the error in question.

誰ツ都不明白 2024-09-23 08:32:22

我在构建QT时遇到了这个问题。我在某处读到的说明建议我使用 VS 命令提示符配置 nmake。

我选择了 x64 命令提示符并轻松执行配置。当我尝试 nmake 时,它​​给出了这个错误。

我认为某些组件是为 32 位预先构建的。该错误甚至报告了哪些模块是为 x86 构建的。

我使用了 32 位默认的 VS 命令提示符,它起作用了。

I came across this problem when building QT. The instructions I read somewhere suggested that I configure nmake using VS command prompt.

I chose the x64 command prompt and performed configure without much hassle. When i tried nmake, it gave this error.

I think some of the components were pre-built for 32-bit. The error even reported which modules were built for x86.

I used the 32 bit default VS command prompt and it worked.

心碎无痕… 2024-09-23 08:32:22
"project property - CUDA Runtime API - GPU - NVCC Compilation Type"

设置64位编译选项 -m64 -cubin

提示在编译日志中。
就像这样:

nvcc.exe ~~~~~~ -machine 32 -ccbin ~~~~~

"-machine 32" 是有问题的。

首先设置64位编译选项,
接下来重新设置混合编译选项。
然后就可以看到成功了。

"project property - CUDA Runtime API - GPU - NVCC Compilation Type"

Set the 64 bit compile option -m64 -cubin

The hint is at compile log.
Like this:

nvcc.exe ~~~~~~ -machine 32 -ccbin ~~~~~

That "-machine 32" is problem.

First set 64bit compile option,
next re setting hybrid compile option.
Then u can see the succeed.

堇年纸鸢 2024-09-23 08:32:22

在 Visual Studio 2013 中,

1) 检查项目属性页/配置属性/链接器/所有选项并更正所有未配置的计算机和目录。

2) 检查项目属性页/配置属性/链接器/输入并更正所有未配置的目录。

参见示例 1)

In Visual Studio 2013,

1) Check in the Project Property Pages / Configuration Properties / Linker / All Options and correct all the miss configured machine and directories.

2) Check in the Project Property Pages / Configuration Properties / Linker / Input and correct all the miss configured directories.

See example of 1)

圈圈圆圆圈圈 2024-09-23 08:32:22

我的目标是 C 语言的 x64 Windows 10 文本模式 DOSBox 应用程序。
使用“Visual Studio 2019 Community”通过DOS提示符“nmake -f makefile”进行编译。
错误类似但相反:

fatal error LNK1112: module machine type 'x32' conflicts with target machine type 'X64'

在另一台电脑上用VC++ 2010编译就可以了。但“Visual Studio 2019 Community”在这台计算机上失败了。所以我的设置是正确的,以上所有答案都不起作用。

我想跟大家分享的是,解决方案是一个这样的make.bat:

call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" 
nmake -f makefile

你会发现还有很多其他的vcvarsxxxx.bat,只有这一个字。

My target is a x64 Windows 10 text mode DOSBox application in C language.
Using "Visual Studio 2019 Community" to compile through DOS prompt "nmake -f makefile".
The error is similar but on the opposite side:

fatal error LNK1112: module machine type 'x32' conflicts with target machine type 'X64'

It's ok to compile by VC++ 2010 on another computer. But failed on this computer by "Visual Studio 2019 Community". So my settings are correct and all above answers do not work.

I'd like to share you that the solution is a make.bat like this:

call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" 
nmake -f makefile

You will find there are many other vcvarsxxxx.bat, only this one words.

如痴如狂 2024-09-23 08:32:22

如果您的解决方案有 lib 项目,请检查“属性”->“库管理器”->“常规”中的“目标计算机”属性

If your solution has lib projects check Target Machine property in Property->Librarian->General

要走就滚别墨迹 2024-09-23 08:32:22

vcxproj 文件可能包含“MACHINE:i386”
使用编辑器编辑 vcxproj 文件。删除它!

vcxproj file may contain 'MACHINE:i386'
Edit vcxproj file with editor. remove it !

多孤肩上扛 2024-09-23 08:32:22

就我而言,将环境变量 PROCESSOR_ARCHITECTURE 设置为 AMD64
解决了问题。

https://social.msdn.microsoft。 com/Forums/en-US/f9303904-81ce-405d-85b3-b66d97e49971

In my case, setting environment variable PROCESSOR_ARCHITECTURE to AMD64
fixed the problem.

https://social.msdn.microsoft.com/Forums/en-US/f9303904-81ce-405d-85b3-b66d97e49971

离去的眼神 2024-09-23 08:32:22

属性->配置管理器->主动解决方案平台。这里选择x64。仅此而已。

它应该处理所有依赖关系并且编译应该顺利进行

Properties->configurationManager-> ActiveSolutionPlatform . Here select x64 .thats all.

It should take care of all dependencies and compilation should work smoothly

千柳 2024-09-23 08:32:22

直接编辑vcxproj文件

 <Link>
      <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>

Erase /MACHINE:I386

Edit vcxproj file directly

 <Link>
      <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>

Erase /MACHINE:I386

夏日落 2024-09-23 08:32:22

除了 Jhonson 的列表之外,还要检查库的文件夹

在 Visual Studio 中,选择“工具”>“库”。主菜单中的选项。选择项目和解决方案 > VC++ 目录。从平台下拉列表中选择 x64。

$(VCInstallDir)lib\AMD64;
$(VCInstallDir)atlmfc\lib\amd64;
$(WindowsSdkDir)lib\x64;

In addition to Jhonson's list, also check library's folders

In visual studio, select Tools > Options from the main menu. select Projects and Solutions > VC++ Directories. Select x64 from the Platform dropdown.

$(VCInstallDir)lib\AMD64;
$(VCInstallDir)atlmfc\lib\amd64;
$(WindowsSdkDir)lib\x64;
燃情 2024-09-23 08:32:22

今天发生在我身上,因为我在 x86 模式下添加了一个库目录,并意外删除了继承的目录,使它们硬编码。
然后切换到 x64 后,我的 VC++ 目录仍然显示:

“...;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);”

而不是 _x64。

This happened to me today because I had added a library directory while still in x86 mode, and accidently removed the inherited directories, making them hardcoded instead.
Then after switching to x64, my VC++ Directories still read:

"...;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);"

instead of the _x64.

那请放手 2024-09-23 08:32:22

我正在使用 CMake &然后添加了win32配置。属性页显示x86,但实际上在文本编辑器中打开 vcxproj 文件时它是 x64!手动更改为 x86 解决了这个问题。

I was using CMake & then added a win32 configuration. The property page showed x86 but actually when opening the vcxproj file in a text editor it was x64! Manually changing to x86 solved this.

怼怹恏 2024-09-23 08:32:22

首先尝试以下操作:
1. 转到配置管理器并创建一个新的 x64(如果尚不存在)。
2.选择x64解决方案。
3. 转到项目属性,然后 Linker->Advanced 选择 x64 机器。
4. 现在重建解决方案。

如果仍然出现同样的错误。尝试干净的解决方案,然后再次重建并打开 Visual Studio,您将获得最近打开的项目的列表,右键单击该项目并将其从那里删除。现在转到解决方案并再次重新打开该解决方案。

First of all try the following things:
1. goto configuration Manager and create a new x64 if it is not already there.
2. select the x64 solution.
3. go to project properties and then Linker->Advanced select x64 machine.
4. Now rebuild the solution.

If still you are getting the same error. try clean solution and then rebuild again and open visual studio you will get list of recent opened project , right click on the project and remove it from there. Now go to the solution and reopen the solution again.

梦巷 2024-09-23 08:32:22

这是一个非常令人沮丧和烦人的问题,但一旦你理解了它,它就变得非常简单:你正在构建构建一种架构类型(在你的例子中是 x64)的一些元素,尽管事实上它是另一种类型的目标(比如 x86) )。

您可以通过查看哪个 obj 文件导致崩溃来剖析问题的根源,并开始在那里查找问题。每个 obj 都会有一个源代码模拟:无论是 cpp、c、asm 等。它周围可能存在使用错误工具的特殊构建事件。在属性表中检查这一点。

在查看 C Johnson 要做的事情清单之前,我会先看看那里。

It's a very frustrating and annoying problem but once you understand it, it's quite simple: you have some element in you're build that building one architecture type (in your case x64) despite the fact that it's been target for another type (say x86).

You can dissect the source of your problem by looking at which obj file is causing the crash and start looking for the problem there. Every obj will have a source code analog: either in cpp, c, asm etc. There may be special build events around it that are using the wrong tool. Check for that in the property sheets.

I'd look there first before going through C Johnson list of things to do.

稳稳的幸福 2024-09-23 08:32:22


我通过在 Visual Studio 2013 中将 Win32 更改为 *64 解决了这个问题。


I solved this problem by changing Win32 to *64 in Visual Studio 2013.

听风念你 2024-09-23 08:32:22

上面有很多很好的建议。

另外,如果您尝试在 x86 Win32 中构建:

请确保您在 Program Files(x86) 中链接到的任何库实际上是 x86 库,因为它们不一定......

例如我在 C:\Program 中链接到的 lib 文件Files (x86)\Microsoft Visual Studio\2019\Professional\SDK 引发了该错误,最终我在 C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86 中找到了它的 x86 版本一切都很好。

Many good suggestions above.

Also if you are trying to build in x86 Win32:

Make sure that any libraries you link to in Program Files(x86) are actually x86 libraries because they are not necessarily...

For example a lib file I linked to in C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\SDK threw that error, eventually I found an x86 version of it in C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86 and everything worked fine.

梦过后 2024-09-23 08:32:22

模块机器类型是您正在编译的机器,目标机器类型是您为其构建二进制文件的架构 x86 或 x64。

module machine type is the machine on which you are compiling and the target machine type is the the architecture x86 or x64 for which you are building your binaries.

陌上芳菲 2024-09-23 08:32:22

如果您的项目在项目属性 -> 中设置为具有相同的中间目录,也可能会发生此问题。配置属性->一般的

This problem may also happen if your project set up to have the same intermediate directories in Project Properties -> Configuration Properties -> General

淡淡绿茶香 2024-09-23 08:32:22

当我将 VS2008 解决方案转换为 VS2010 时,就会发生这种情况将win32配置更改为X64,在我的旧解决方案中,我有mfcs90d.lib(配置->链接器->输入->其他依赖项),因为我使用的是VS010,我刚刚检查了VS2010文件夹,其中是mfcs100d.lib,所以我在(配置->链接器->输入->其他依赖项)中将 mfcs90d.lib 更改为 mfcs100d.lib 它工作正常。

this happens to me when i convert my VS2008 solution to VS2010 & change win32 configuration to X64, in my old solution I have mfcs90d.lib (Configuration->Linker->Input->Additional dependencies), as I am using VS010 i just checked in VS2010 folder where it is mfcs100d.lib, so I changed mfcs90d.lib to mfcs100d.lib in (Configuration->Linker->Input->Additional dependencies) it worked fine.

山川志 2024-09-23 08:32:22

对于那些使用 QT Creator 的人来说,问题是相同的(如 @c-johnson 所描述)。
确保套件中 MSVC 的编译器设置设置为 x86,如下所示。

QT Creator MSVC x86 编译器的套件设置

For those who are with QT Creator, the issue is same (as described by @c-johnson).
Make sure the compiler settings for MSVC in your kit is set to x86 as shown below.

QT Creator Kit Settings for MSVC x86 compiler

泅人 2024-09-23 08:32:22

对于某些使用命令提示符(dos 提示符)的人
这可能会有所帮助:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" --help
Error in script usage. The correct usage is:
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option]
  or
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store
  or
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] [version number]
  or
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store [version number]
where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK
:
The store parameter sets environment variables to support
  store (rather than desktop) development.
:
For example:
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 10.0.10240.0
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store 10.0.10240.0
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 8.1
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 store 8.1
:
Please make sure either Visual Studio or C++ Build SKU is installed.

另外,如果您这样做:

CL "%1%2%3" /EHsc /link user32.lib Gdi32.lib Winmm.lib comctl32.lib *.obj /SUBSYSTEM: CONSOLE /MACHINE:x86

你必须del *.obj 之前;以避免混淆链接器与先前编译留下的 64 位和 32 位对象?

for some using command prompt (dos prompt)
this might be helpful:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" --help
Error in script usage. The correct usage is:
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option]
  or
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store
  or
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] [version number]
  or
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store [version number]
where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK
:
The store parameter sets environment variables to support
  store (rather than desktop) development.
:
For example:
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 10.0.10240.0
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store 10.0.10240.0
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 8.1
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 store 8.1
:
Please make sure either Visual Studio or C++ Build SKU is installed.

Also If you do like this:

CL "%1%2%3" /EHsc /link user32.lib Gdi32.lib Winmm.lib comctl32.lib *.obj /SUBSYSTEM:CONSOLE /MACHINE:x86

you have to del *.obj before; to avoid confusing linker with both 64 and 32 bit objects left over from prior compilations?

错々过的事 2024-09-23 08:32:22

我已经为自己解决了这个问题,如下所示。

首先,我遵循了这个问题的其他答案,结果得出结论:所有项目设置都是正确的。

然后我用编辑器检查了 .vcxproj 文件,并注意到 <链接>两个(调试和发布)x64 配置的属性未指定 < TargetMachine >,而 Win32 配置都包含 <目标机器>机器X86 /目标机器>。

但是,我已经验证过,从 Visual Studio 的“属性”>“查看”配置属性>链接器>高级>目标机器,x64 配置表示 MachineX64 (/MACHINE:X64)。

因此,我编辑了 .vcxproj 文件以包含 <目标机器>机器X64 < /目标机器>在两个 x64 配置中。返回到 Visual Studio 项目属性对话框,我注意到 MachineX64 (/MACHINE:X64) 设置与以前一样存在,只是现在它以粗体显示(显然意味着该值不是默认值)。

我重建了,并且成功了。

I have fixed this problem for myself as follows.

First of all, I followed the other answers for this question, only to conclude that all the project settings were correct.

Then I inspected the .vcxproj file with an editor and noticed that the < Link > properties for the two (Debug and Release) x64 configurations did not specify < TargetMachine >, while the Win32 configurations both contained < TargetMachine > MachineX86 < /TargetMachine >.

However, I had already verified, looking from Visual Studio at Properties > Configuration Properties > Linker > Advanced > Target Machine, that the x64 configurations said MachineX64 (/MACHINE:X64).

So, I edited the .vcxproj file to include < TargetMachine > MachineX64 < /TargetMachine > in the two x64 configs. Going back to the Visual Studio project properties dialog, I noticed that the MachineX64 (/MACHINE:X64) setting was there as before, except that now it showed in bold (apparently meaning that the value is not the default one).

I rebuilt, and it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文