LNK1158:无法与VC ++ / VS2010针对64位编译不能运行的Cvtres.exe [英] Cannot compile with VC++/VS2010 targeting x64: LNK1158: cannot run cvtres.exe

查看:4921
本文介绍了LNK1158:无法与VC ++ / VS2010针对64位编译不能运行的Cvtres.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个C#开发人员,我最近决定采取裂缝在写一些C ++程序,主要是因为我发现一个有趣的C ++ API,我想玩弄。我前几天写了一个非常简单的程序,编译它的x64目标平台上,运行它,一切都还只是桃色。

As a C# developer, I recently decided to take a crack at writing some C++ programs, mainly because I found an interesting C++ API I wanted to play around with. I wrote a very simple program a few days ago, compiled it on the x64 target platform, ran it, and everything was just peachy.

不过,昨天我改变了一些code,试图编译它,但随后的链接开始抱怨:

However, yesterday I changed some of the code, tried to compile it, but then the linker started to complain:

LNK1158:无法运行的Cvtres.exe

由于我很新开发的C ++程序,我想我一定做了一些初学者的错误。然而,检查所有的配置,谷歌搜索了几个小时,并尝试一些修正之后,我开始想这个问题可能是由于更多的东西代表引起的,问题是:我似乎无法来解决该问题在所有,所以我希望能在这里得到一些好的反馈。

As I am quite new to developing C++ programs, I thought I must had made some beginner's mistake. However, after checking all configuration, searching google for several hours, and trying several 'fixes', I'm starting to think this problem might be caused by something more delegate, and the point is: I cannot seem to resolve the issue at all, so I was hoping to get some good feedback here.

首先,让我列举一下我的配置:

First of all, let me list my configuration:

  • 在我运行Windows 7(64位)和正在使用VS2010 premium。
  • 在我创建了一个标准的空Win32控制台应用程序只有一个单一的.cpp文件里面包含的主要功能。这不是一个Hello World程序,但为期不远了。
  • 因为我有一个x64平台,我还使用了x64的目标平台配置。我创造了这个配置,而从Win32配置复制任何设置。
  • 在项目属性 - > VC ++目录,我将所有的目录为默认值(虽然我没有改变他们几次试图解决这个问题,但没有成功,于是我又回到了默认设置)

这最后一点似乎是至关重要的,因为VC ++目录设置决定哪些编译器和连接器的使用。在这一点上,居住在 $(VCInstallDir)斌交叉编译\ x86_amd64 -directory使用。此外,所有其他目录似乎指向64的所有库的版本等。

This last point seems to be crucial, since the VC++ Directory settings determine which compiler and linker are used. At this point, the cross-compiler residing in the $(VCInstallDir)bin\x86_amd64-directory is used. Furthermore, all other directories seem to point at x64 versions of all libraries and so on.

在谷歌这个问题,你会发现,使用的链接器(LINK.EXE)要执行的Cvtres.exe,它无法找到。此问题似乎当的Cvtres.exe既不在同一目录链接器,也不能在正在使用的PATH变量决定的目录出现。

When you google this problem, you will find out that the linker used (link.exe) wants to execute cvtres.exe, which it cannot find. This problem seems to occur when cvtres.exe is neither in the same directory as the linker, nor in a directory that is resolved using the PATH-variable.

所以,我验证了这也的确是在 $(VCInstallDir)BIN \ x86_amd64 (虽然也有它的基础目录(版本的 $没有Cvtres.exe版本( VCInstallDir)斌),并在纯的 $(VCInstallDir)BIN \ AMD64 目录),也没有在PATH变量包含包含版本CVTRES的目录中的任何上市。 exe文件。

So I verified this and there is indeed no version of cvtres.exe in $(VCInstallDir)bin\x86_amd64 (though there are versions of it in the base-directory ($(VCInstallDir)bin) and in the 'pure' $(VCInstallDir)bin\amd64 directory), nor does the PATH-variable contain any listing of a directory that contains a version of cvtres.exe.

- 尝试#01 - 解决手头的问题 -

这样一来,你可能会得出这样的结论是错误的,其实,一个法律失效,我应该通过直接在 $(VCInstallDir)BIN \ x86_amd64 目录,或编辑路径变量,使其指向它的可用版本。

As a result, you might conclude that the error is, in fact, a legal failure and I should fix this by either copying a version of cvtres.exe directly in the $(VCInstallDir)bin\x86_amd64 directory, or edit the PATH-variable as such that it points to usable version of it.

不幸的是,没有工作的。

Unfortunately, none of this works.

在我的Cvtres.exe复制从 $(VCInstallDir)斌 $(VCInstallDir)BIN \ AMD64 $(VCInstallDir)BIN \ x86_amd64 和编译,我要么得到了同样的信息(现指的确切位置:不能运行的 $(VCInstallDir)BIN \ x86_amd64 \的Cvtres.exe ,但它的存在),或者连接器出口与一些未知的错误 - code(可能是因为 $(VCInstallDir)BIN \ AMD64版本是不同于x86的交叉编译器,我已经找到了原生的x64处于运行状态了WoW64模式)。

When I copy cvtres.exe from $(VCInstallDir)bin or $(VCInstallDir)bin\amd64 to $(VCInstallDir)bin\x86_amd64 and compile, I either get the same message (now referring to the exact location: 'cannot run $(VCInstallDir)bin\x86_amd64\cvtres.exe', though it is there) or the linker exits with some unknown error-code (probably because the version of $(VCInstallDir)bin\amd64 is native x64 unlike the x86 cross-compiler which I have found out to be running in WoW64 mode).

与尝试编辑的问题PATH变量,使得连接器可以找到一个Cvtres.exe版本也失败了,因为我不知道有路径来引用(似乎还有更多版本的Cvtres.exe保持在不同的地点,也可以在.NET 4.0 SDK目录例如)。

The problem with attempting to edit the PATH-variable such that the linker can find a version cvtres.exe also fails because I don't know with path to refer to (it seems there are many more versions of cvtres.exe kept in various locations, also in the .NET 4.0 SDK directory for example).

- 尝试#02 - 通过尝试不同的方法绕过这个问题 -

这是我采取的另一途径是尝试使用,而不是交叉编译器编译器和链接在 $(VCInstallDir)BIN \ AMD64 。毕竟,我是运行64位的机器,所以我不应该需要使用交叉编译器,但微软似乎选择这一项默认情况下,无论你的本地配置/ OS的。

Another path that I have taken is to try to use the compiler and linker in the $(VCInstallDir)bin\amd64 instead of the cross-compiler. After all, I am running a 64-bit machine so I shouldn't need to use the cross-compiler, though Microsoft seems to choose this one by default, regardless of your local configuration/OS.

于是,我改变了VC ++目录指向这个地址确实是问题不再出现,但现在我有一个跟踪,问题运行CL.EXE代替:

So I changed the VC++ Directory to point to this location and indeed the problem no longer occurs, but now I got a tracker-problem running the CL.exe instead:

TRK0002:[CL.EXE]'@临时文件] .rsp:无效的句柄

当我寻找这个临时文件,我不能找到它,但我不知道它是否编译后立即删除完成,或者是从来没有present的。不幸的是,谷歌搜索这个问题是死路一条也和<一href="http://connect.microsoft.com/VisualStudio/feedback/details/505682/x64-c-c-projects-cannot-compile">MS Visual Studio 2010的团队,即使认识到这个问题,但已经把它不会解决。总之,编译原生64位似乎是一个已知的,一般以VS2010的问题,所以我决定去回到原点就这一个,特别是因为有其他人这个问题总是说'好,你可以通过只解决这个问题使用原生64位编译器'的交叉编译器来代替。

When I look for this temp-file I cannot find it, but I'm not sure whether it is immediately deleted after compilation 'completed' or it was never present at all. Unfortunately, googling this issue is a dead end also, and MS Visual Studio 2010 team even recognise this issue but have put it on 'Won't Fix'. In short, compiling natively 64-bit seems to be a known, general problem with VS2010, so I decided to go back to square one on this one, especially since other people having this problem always say 'well you can fix this problem by just using the cross-compiler instead of the native x64 compiler'.

好了,现在我发现自己跑出来的选项...,疯狂的事情是,它都能正常运作短短数天前,我是pretty的肯定,我并没有改变或安装有关的事项目,也没有更新的Visual Studio或.NET Framework不知。我甚至检查的Windows更新,但无法找到过去的几天里任何相关的更新。

OK, so now I find myself running out of options... And the crazy thing is that it all worked fine just a few days ago and I'm pretty sure I did not change or install anything regarding this project, nor updated Visual Studio or the .NET Framework somehow. I even checked the Windows Updated but can't find any related updates for the last few days.

我能做的唯一的事情,真正作为最后的手段,是降级整个事情为32位并下载32位版本的API,但我真的想避免这种情况,因为它似乎对我来说,我应该可以编译和我的64位笔记本电脑/ OS上运行64位应用程序。

The only thing I could do, really as a last resort, is to downgrade the whole thing to 32-bit and download the 32-bit version of the API, but I'd really want to avoid this one because it seems to me I should be able to compile and run 64-bit applications on my 64-bit laptop/OS.

所以,请有什么建议?

更新的:据 href="http://msdn.microsoft.com/en-us/library/aa448630.aspx">该指令, PATH变量的链接必须指向在VC的基本目录++安装。那是在 $(VCInstallDir)斌我一直在谈论。我曾经试过,但没有解决问题。我想知道什么是发生在后台,当VS版本是解雇,我似乎不知道......

Update: According to this instruction from MS, the PATH-variable for the linker has to point at the base-directory of the VC++ install. That is the $(VCInstallDir)bin I have been talking about. I have tried this, but does not solve the issue. I am wondering what is happening in the background when a VS Build is fired that I don't seem to know of...

@Hans帕桑特:日Thnx的小费!进程监视器显示我LINK.EXE正在试图寻找的Cvtres.exe在以下位置之一:

@Hans Passant: Thnx for the tip! Process Monitor shows me that link.exe is trying to find cvtres.exe on one of following locations:

  • $(VCInstallDir)BIN \ x86_amd64
  • $(SourceFileDir)
  • C:\ WINDOWS \ SYSTEM32 \ NV

不用说,的Cvtres.exe存在于没有这些目录。这是相当奇怪的只有的这些位置进行搜索。我想至少期望的 $(VCInstallDir)斌被搜查,因为该目录是在这两个VC ++目录并明确列出的路径变量(我手动editted为了这个目的)。我想这可以归结为findout为什么这种行为是因为它是....

Needless to say, cvtres.exe exists in none of these directories. It's rather strange that only those locations are searched. I would at least expect that $(VCInstallDir)bin was searched, since this directory is explicitly listed in both the VC++ Directories and in the PATH-variable (which I editted manually for this purpose). I guess this comes down to findout out why this behaviour is as it is....

UPDATE2 的:只是把一些额外的信息,我决定从 $(VCInstallDir)斌 $复制的Cvtres.exe(VCInstallDir)斌\ x86_amd64 目录的基础上,使用procmon中,只是为了看看发生了什么事,然后我的发现。首先,像以前一样,Visual Studio中告诉我下面的:

Update2: Just to put out some extra info, I decided to copy cvtres.exe from the $(VCInstallDir)bin to the $(VCInstallDir)bin\x86_amd64 directory, based on my findings using ProcMon, just to see what was happening then. First of all, as before, Visual Studio tells me the following:

C:\ Program Files文件(x86)的\的MSBuild \ Microsoft.Cpp \ V4.0 \平台\ 64 \ Microsoft.Cpp.x64.Targets(389,5):错误MSB6006:LINK.EXE退出,code -1073741515 的(这里的行只是指设置,检查这非零×[出口codeS是可以接受的 - 实际无差错code是通过链接返回。 exe文件。)

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(389,5): error MSB6006: "link.exe" exited with code -1073741515. (The line here just refers to a settings that checks which non-zero exit-codes are acceptable - the actual error-code was returned by link.exe.)

不过,在procmon中的输出窗口,我可以看到的Cvtres.exe被发现,正在执行大量的工作 - 来完成,因为它似乎,但我不是很肯定。不管怎样,错误仍然prevents我从执行创建可执行文件,因为它抱怨某个引用的库没有被发现。这可能是由于这样的事实,接头没有正确完成,所以在短,它不能解决我的问题这里。

However, in the output Window of ProcMon I can see that cvtres.exe is found and is performing a large amount of work - to completion as it seems, but I am not quite sure about that. Anyway, the error still prevents me from executing the created executable, since it complains a certain referenced library was not found. This is probably due to the fact that the linker did not finish correctly, so in short, it does not resolve my issue here.

UPDATE3 的:另外一个有趣的事情,我想是只创建一个新的,普通的Win32项目,所有的MS违约,我甚至没有触及这对我来说是产生code (main函数立即返回),正好看到至少有一个程序编译。令人惊奇的是,我现在得到了同样的错误与上述(LINK.EXE退出,code -1073741515),所以现在我真的开始觉得有什么是真正的错在这里我安装。

Update3: Another 'interesting' thing I tried was to just create a new, plain Win32 project with all MS defaults and I didn't even touch the code that is generated for me (a main function returning immediately), just to see at least a single program compile. Suprisingly, I now get the same error as above (link.exe exited with code -1073741515), so now I really start to think something's really wrong with my installation here.

于是我试图脱离和重新安装VC ++的Visual Studio的一部分,但都无济于事......此时的Visual Studio的完全安装是没有选择,因为我也仍然在开发C#中间项目和我有吨安装,仅仅花太多的我的时间,此刻重新安装和重新配置等加载项。我可能会在周末试试这个,如果没有制定了再说吧。

So then I tried to de- and reinstall the VC++ parts of Visual Studio, but to no avail... At this point a full install of Visual Studio is no option since I'm also still in the middle of developing C# projects and I have tons of other add-ins installed that just take too much of my time at the moment to re-install and reconfigure. I might try this in the weekend if nothing has worked out until then.

相反,我做了错误code一些研究,我认为这是与事实,LINK.EXE无法找到或访问它需要的依赖。我已经关掉我的VirusScanner为了安全起见(没有帮助),所以现在我下载最新的Windows SDK(7.1),看看能否做任何事情。如果这样做没有帮助,我想这可以是一个可怕的错误,或者我安装的是真的搞砸了某个地方,我可能需要重新安装VS和它所有的东西...

Instead, I did some research on the error code and I think it has something to do with the fact that link.exe cannot find or access a dependency it requires. I already turned off my VirusScanner just to be safe (doesn't help), so now I'm downloading the latest Windows SDK (7.1) to see if that does anything. If that doesn't help, I'm guess it is either a terrible bug, or my installation is really screwed up somewhere and I might have to reinstall VS and all it's stuff...

感谢反正建议!

推荐答案

C:\ WINDOWS \ SYSTEM32 \ NV 路径可以指向一个问题,就是讨论<一个href="http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/path-variable-shows-only-pathcwindowssystem32nv/454fd1fb-84b0-439a-9a42-6d93ef15e074"相对=nofollow>这里和这里

The C:\Windows\System32\NV path could point to a problem that is discussed here and here.

这似乎有些NVIDIA驱动程序,可切换显卡模式(集成/独立)可能会破坏在某些情况下系统路径(例如,使用系统路径上的英特尔无线路径)。

It seems some NVIDIA drivers that can switch graphics modes (integrated/discrete) can corrupt the system path in certain situations (e.g. with Intel Wireless paths on the system path).

禁用NV Services服务可以解决你的问题。

Disabling the NV Services service may solve your problem.

这篇关于LNK1158:无法与VC ++ / VS2010针对64位编译不能运行的Cvtres.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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