Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VC++ fatal error LNK1168: cannot open filename.exe for writing

Suddenly, my Visual Studio Express 2010 C++ stopped rebuilding my project. When I first hit F7 the project builds and runs fine (heck, it's a hello world example).

Then I make some changes and hit F7 again, then I get:

1>LINK : fatal error LNK1168: cannot open C:\Users\username\Documents\Visual Studio 2010\Projects\console\Debug\console.exe for writing**<br><br> 

Now the funny thing comes:

  1. The app is not running and it's not shown in the Task Manager.
  2. Going into the project directory and trying to remove it with hands comes with success but the file APPEARS AGAIN FROM NOWHERE.
  3. The system restore is disabled.
  4. I also tried to take the ownership of the whole damn drive.
  5. Every time I delete the file it recreates itself again but sometimes it stops doing that.
  6. If I delete the file (and it recreates after that), and then I start sysinternals procmon then the file disappears.
  7. If I start procmon before - then the file keeps appearing after delete like always.

OS: W7 SP1 64-bit, with latest updates

Any ideas, please?

like image 609
gogiii Avatar asked Aug 25 '12 17:08

gogiii


People also ask

How to fix lnk1168 error?

To fix this issue, verify that the filename file handle is not locked, and that you have write permission for the file. If it is an executable, verify that it is not already running. You can use the Windows SysInternals utilities Handle or Process Explorer to determine which process has a file handle lock on filename .

How do I fix error lnk1104?

To fix this issue, stop the program and unload it from the debugger before building it again. If the app is open in another program, such as a resource editor, close it. If your program is unresponsive, you may need to use Task Manager to end the process. You might also need to close and restart Visual Studio.


1 Answers

The problem is probably that you forgot to close the program and that you instead have the program running in the background.

Find the console window where the exe file program is running, and close it by clicking the X in the upper right corner. Then try to recompile the program. In my case this solved the problem.

I know this posting is old, but I am answering for the other people like me who find this through the search engines.

like image 181
CodeMed Avatar answered Sep 24 '22 00:09

CodeMed