views:

41

answers:

1

I was just coding on my Lazarus, without changing nothing on the TForm declarations. Then I tried to test my application, but on the compilation I got this error:

TomAct.lpr(11,43) Error: Duplicate identifier "TOMACT"
TomAct.lpr(15,32) Error: Identifier not found "TForm1"
TomAct.lpr(15,39) Error: Identifier not found "Form1"
TomAct.lpr(19) Fatal: There were 3 errors compiling module, stopping

And here is the content of my *.lpr file:

program TomAct;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms
  { you can add units after this }, TomAct;

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

What I need to do?

+1  A: 

Evidently, you have a unit named TomAct, but your project is also named TomAct. Pick a different name for your project or the unit where your form is defined.

The first error, about the duplicate identifier, is because the compiler thinks you're trying to "use" the project itself, which isn't allowed. It issues an error message and continues compiling without using the unit.

The undeclared-identifier errors are side effects of the first error. Since the unit has not been used, the compiler doesn't know about the type and variable declared in it.

Rob Kennedy
Ok, but how I can rename the project name without causing other problems? Because it isn't just renaming the *.lpr file.
Nathan Campos
Doesn't Lazarus have a "save as" command in the File menu? That's the way to do it in Delphi.
Rob Kennedy
@Rob: I'm still getting the same error. **:(**
Nathan Campos
So, the file name *and* the `program` line in the file both use a name that *isn't* `tomact`, and yet the compiler still reports on line 11 that you have a duplicate identifier named `tomact`? If that's really the case, then I'm afraid I give up. Start over with a new blank project and add your unit to it instead.
Rob Kennedy
Yes, but I saw that everytime that I try to Run it, Lazarus re-create the old TomAct.lpr and use it. What I can do?
Nathan Campos