Hello when I compile this piece of program written in pascal with gpc (GNU pascal for linux) for pascal, I get errors:

cradle: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib/crt1.o:(.text+0x0): first defined here
cradle: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib/crti.o:(.fini+0x0): first defined here
cradle:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
cradle: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib/crt1.o:(.data+0x0): first defined here
cradle: In function `__data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.1.3/crtbegin.o:(.data+0x0): first defined here
cradle: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib/crti.o:(.init+0x0): first defined here
/tmp/ccu2saxU.o: In function `_p__M0_main_program':
1.1.p:(.text+0x7d9): multiple definition of `_p__M0_main_program'
cradle:(.text+0xa13): first defined here
/tmp/ccu2saxU.o: In function `_p__M0_init':
1.1.p:(.text+0x7e4): multiple definition of `_p__M0_init'
cradle:(.text+0xa23): first defined here
/tmp/ccu2saxU.o: In function `main':
1.1.p:(.text+0x804): multiple definition of `main'
cradle:(.text+0xa43): first defined here
/usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
/usr/bin/ld: error in cradle(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status


program Cradle;

{ Constant Declarations }
const TAB = ^I;

{ Variable Declarations }
var Look: char;              { Lookahead Character }

{ Read New Character From Input Stream }
procedure GetChar;
begin
   Read(Look);
end;

{ Report an Error }
procedure Error(s: string);
begin
   WriteLn;
   WriteLn(^G, 'Error: ', s, '.');
end;

{ Report Error and Halt }
procedure Abort(s: string);
begin
   Error(s);
   Halt;
end;

{ Report What Was Expected }
procedure Expected(s: string);
begin
   Abort(s + ' Expected');
end;

{ Match a Specific Input Character }
procedure Match(x: char);
begin
   if Look = x then GetChar
   else Expected('''' + x + '''');
end;

{ Recognize an Alpha Character }
function IsAlpha(c: char): boolean;
begin
   IsAlpha := upcase(c) in ['A'..'Z'];
end;

{ Recognize a Decimal Digit }
function IsDigit(c: char): boolean;
begin
   IsDigit := c in ['0'..'9'];
end;

{ Get an Identifier }
function GetName: char;
begin
   if not IsAlpha(Look) then Expected('Name');
   GetName := UpCase(Look);
   GetChar;
end;

{ Get a Number }
function GetNum: char;
begin
   if not IsDigit(Look) then Expected('Integer');
   GetNum := Look;
   GetChar;
end;

{ Output a String with Tab }
procedure Emit(s: string);
begin
   Write(TAB, s);
end;

{ Output a String with Tab and CRLF }
procedure EmitLn(s: string);
begin
   Emit(s);
   WriteLn;
end;

{ Initialize }
procedure Init;
begin
   GetChar
end;

{ Main Program }
begin
   Init;
end.

Edited 3 Years Ago by blob84

How are your building/linking this? The errors indicate that you are trying to link multiple versions (or copies) of the named functions, resulting in the "multiple definition" errors.

i found the problem, there is an output file with the same name of the binary output file, gcc overwrite it but this doesn't happen with gpc.

Edited 3 Years Ago by blob84

This article has been dead for over six months. Start a new discussion instead.