So I am using Visual Studio 19. I just started a new plain C++ project. It builds and I can run it. But after changing anything within the code, the next time it would not build and rather yield the following:
Build started...
1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>Test.cpp
1>LINK : fatal error LNK1104: cannot open file 'F:\...\Test\Test\Debug\Test.exe'
1>Done building project "Test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Even after changing everything back to the original code, I get the exact same result. After a PC restart, I still get this output. Even when I then create a new project again I get that error. After some time it randomly worked again, but once I changed something it broke again. I could not reproduce this and the behaviour seems to be irregular.
But I also do not have any exe file within my Debug folder (only the first time, when the build succeeded.)
Most websites suggest: Either the exe is still running, or the includes are misspelt. But since this is the default hello world program and it worked once, it cannot be the latter. And it is also not the former one because, after a PC restart, I still got the error message.
So as pointed out by Richard it actually was the antivirus that ran my application in the background. I fixed it by simply adding an exception for the whole application folder.