visual-studiovisual-c++visual-studio-2022

How to set Visual Studio to AVOID "VC++ fatal error LNK1168: cannot open filename.exe for writing"


READ VERY CAREFULLY BEFORE FLAGGING AS A DUPLICATE QUESTION.

I've used Visual Studio, most versions since version 6.0. I just started getting the error

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

on

Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.1.3

There are several other questions on this forum asking in effect how to get rid of the error but the specific question allows for--and receives--manual solutions: manually close the debug output window, manually find the file and delete it, manually find in the task manager or resource monitor, manually reboot, etc. etc.

I am not asking what manual procedure makes this error go away. Instead I am asking if there's a way or a convenient Visual Studio procedure to avoid having the error in the first place, for instance to have Visual Studio kill the binary on shift-F5 (Debug Stop) or recompile or some such.

I just started a little throwaway project. It outputs to a terminal. It hits a breakpoint or crashes. I fix the code and by reflex hit shift-F5 F5 (Debug Stop; Debug) as I think I've done for 25 years, and now am always getting this error, because I don't manually close the output window. And I don't manually close the output window as I don't recall ever having to do so before.

Granted I normally write GUI programs or daemons, and this little program uses terminal output. Is that the problem?

Or, is has it always been like this but I've somehow rebound shift-F5 to actually kill the process being debugged?

Or is there an Options to check so that shift-F5 also kills the binary?

Or is there an Options to check so that F5 kills the binary?

Or some alternate hotkey sequence I should be using after fixing a bug and wanting a recompile?

Or...?


Solution

  • Set the option (very near the bottom of the list) Tools-->Options-->Debugging-->General-->Automatically close the console when debugging stops

    enter image description here