简体   繁体   English

VisualStudio - 致命错误 LNK1168:无法打开 myfile.exe 进行写入

[英]VisualStudio - Fatal error LNK1168: cannot open myfile.exe for writing

Sometime, while I try to compile my project, VisualStudio show me this error:有时,当我尝试编译我的项目时,VisualStudio 会向我显示此错误:

1>LINK : fatal error LNK1168: cannot open C:\\Path\\myfile.exe for writing 1>LINK : 致命错误 LNK1168: 无法打开 C:\\Path\\myfile.exe 进行写入

and It not allowes me to compile the project.它不允许我编译项目。

It seems that myfile.exe is open and running in background yet, although I closed it.尽管我关闭了它,但似乎myfile.exe已打开并在后台运行。 I opened Win TaskManager but the file is not shown in the list of process running.我打开了 Win TaskManager,但该文件未显示在正在运行的进程列表中。

This error persists and the only solution I found is reboot the system, but it's a tedious way that give me crazy because this error recurs often.此错误仍然存​​在,我找到的唯一解决方案是重新启动系统,但这是一种乏味的方式,让我发疯,因为此错误经常重复出现。

Some ideas to resolve it?一些想法来解决它? Someone had the same error before?以前有人有同样的错误吗?

I had this error already many times.我已经多次遇到此错误。 Though your myfile.exe is not shown in TaskManager, It is present in background yet.尽管您的myfile.exe未显示在 TaskManager 中,但它仍存在于后台。 If you open the cmd as administator and type:如果您以管理员身份打开cmd并键入:

tasklist |任务列表 | FIND "myfile.exe"找到“myfile.exe”

You can see your process running.您可以看到您的进程正在运行。

So at this point type the command:所以此时输入命令:

taskkill /IM myfile.exe /F taskkill /IM myfile.exe /F

in order to force the process kill.为了强制进程终止。

Now, if you try to compile your project again, you'll see the compiler is ok and the error is resolved.现在,如果您再次尝试编译您的项目,您将看到编译器正常并且错误已解决。

Surely it's possible that this error will occur again, so I suggest you to create a .bat file that run the kill command, so you can resolve the problem quickly.肯定有可能再次出现这个错误,所以建议你创建一个运行kill命令的.bat文件,这样可以快速解决问题。

regarding: LNK1168关于:LNK1168

Microsoft has a web page dedicated to this error: Microsoft 有一个专门针对此错误的网页:

LNK1168 LNK1168

The first thing on the linked page is:链接页面上的第一件事是:

The linker can’t write to filename.

The rest of the page discusses the details of why the linker cannot write to the file.本页的其余部分讨论了链接器无法写入文件的详细信息。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM