0
votes

I am using object pascal in lazarus. When I open an old project and attempt to run it; this code window pops up in the source editor:

program TimeKeeper;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, datetimectrls, TimeKeeperU1;

{$R *.res}

begin
  RequireDerivedFormResource := True;
  Application.Initialize;
        Application.CreateForm(TfrmTimeKeeper, frmTimeKeeper);

  Application.Run;
end.   

This code window popup in the source window errors, is paired with these errors:

TimeKeeper.lpr(20,1) Error: Can't create object file: TimeKeeper.exe (error code: 5) TimeKeeper.lpr(20,1) Error: Can't create executable TimeKeeper.exe

Does anyone know what the workaround is?

1
ERROR_ACCESS_DENIED it pays to get to know a few of the more common Win32 error codesDavid Heffernan

1 Answers

3
votes

The error message indicates that the object file can't be created, which results in the application not being created. The error code 5 means access denied, which means you don't have write access to the directory where the compiler and linker are attempting to store output, or the executable is in use and can't be replaced (perhaps by anti-virus software), or it's been made read-only.

If the problem is with rights, the solutionis to either get sufficient rights to the directory or to change the output path of the project to a directory where you do have sufficient rights. This is typically done in Project->Options from the main menu.

If it's due to anti-virus software or another process that's using the executable, disable the AV software or provide an exception rule that prevents scanning that folder.

If the issue is caused by the file being read-only, change the file attributes to remove that attribute.