问题
When running my Delphi Project for the first time , it runs with no error. But the subsequent runs produces an error below:
[dcc32 Fatal Error] F2039 Could not create output file '.\Win32\Debug\Project1_p.exe'
I tried enabling my application Experience and setting it to automatic, as stated here with no luck. How to fix this permanently? Im using Delphi 10.1 Berlin.
UPDATE 1:
I know deleting the .exe, checking whether the executable is still running in the task manager and killing the process are the quick solutions. But I want a permanent fix.
回答1:
You probably are running your application through the Run Without Debugging button (big green arrow Shift+Ctrl+F9), instead of that you should better run it through the Run button (small green arrow inside of a windows F9).
This way not only you can easily fix errors debugging your application line to line, but more importantly, when you stop the debugger (Stop button) the application closes and the executable is no longer in use, so you can recompile without showing that error again.
回答2:
The quick fix that you are looking for does not exist. The compiler cannot write the output file if it is already being used as the executable for a running process.
The solution is to make sure that the process has terminated before you attempt to compile again. Quite plausible, it seems to me, is that there is a bug in your code that means that the process is not terminating when you attempt to close it.
来源:https://stackoverflow.com/questions/39221715/could-not-create-output-file-in-delphi-10-1-berlin