Sometime, while I try to compile my project, VisualStudio show me this error:
1>LINK : fatal error LNK1168: cannot open C:\\Path\\myfile.exe for writing
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. I opened Win TaskManager but the file is not shown in the list of process running.
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. If you open the cmd
as administator and type:
tasklist | FIND "myfile.exe"
You can see your process running.
So at this point type the command:
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.
regarding: LNK1168
Microsoft has a web page dedicated to this error:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.