1

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.

Community
  • 1
  • 1
  • 1
    Look at the other answers in the link as well. Deleting the exe is often a quick fix. – LU RD Aug 30 '16 at 07:52
  • 1
    @LURD -> Thanks. I know it can be fix through it, but I dont want to do it everytime I run my application again. I want a permanent fix. –  Aug 30 '16 at 07:59

4 Answers4

1

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
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.

Marc Guillot
  • 6,090
  • 1
  • 15
  • 42
0

Open your task manager and navigate to processes Close all processes linked with your program, it usually says '.exe' at the end

lmk if it helped!

remo
  • 1
0

If you use Application.Terminate with your main program onclose event will cause this problem, instead use Application.mainform.close

Jimmie
  • 1