Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   FreePascal (https://www.delphipraxis.net/74-freepascal/)
-   -   [GNU/Linux, FPC] Linkerproblem bei SO's (https://www.delphipraxis.net/158273-%5Bgnu-linux-fpc%5D-linkerproblem-bei-sos.html)

implementation 11. Feb 2011 10:56

[GNU/Linux, FPC] Linkerproblem bei SO's
 
Guten Morgen,

ich habe meine Testbibliothek aus diesem Thread etwas erweitert mit einer Variable:
Delphi-Quellcode:
{$mode objfpc}{$longstrings on}

unit CrayLib;

interface

uses CrayInter;

type
   TPowerstaff = class(TInterfacedObject, IPowerstaff)
   public
      procedure Writeln(s: pchar);
   end;
   
procedure Hello;
procedure Bye;
function RequestStaff: IPowerstaff;

implementation

var
   FAppRunning: Boolean;

procedure TPowerstaff.Writeln(s: pchar);
begin
   System.WriteLn(String(s));
end;

procedure Hello;
begin
   if FAppRunning then WriteLn('Error: Application is already running!');
   FAppRunning := true;
end;

procedure Bye;
begin
   if not FAppRunning then WriteLn('Error: Application isn''t running!');
   FAppRunning := false;
end;

function RequestStaff: IPowerstaff;
begin
   Result := TPowerstaff.Create;
end;

initialization
   FAppRunning := false;
end.

// --------------------------------------

library Cray;

uses CrayLib, CrayInter;

procedure println(s: pchar); deprecated;
begin
   WriteLn(String(s));
end;

exports println, bye name 'cfbye', hello name 'cfhello', RequestStaff name 'reqpow';

end.
Leider wird daraus nichts:
Code:
/usr/bin/ld: CrayLib.o: relocation R_X86_64_32S against `U_CRAYLIB_FAPPRUNNING' can not be used when making a shared object; recompile with -fPIC
Wenn ich alle Zeilen auskommentiere, in denen die Variable benutzt wird, gibt es keine Probleme.

Was kann ich machen?

BUG 11. Feb 2011 11:52

AW: [GNU/Linux, FPC] Linkerproblem bei SO's
 
Zitat:

Zitat von /usr/bin/ld (Beitrag 1081017)
recompile with -fPIC


Ohne zu wissen, was dann passiert: Hast du das mal probiert?

PS: Habe was dazu gefunden.

implementation 11. Feb 2011 11:54

AW: [GNU/Linux, FPC] Linkerproblem bei SO's
 
Das Flag ist aber für gcc, beim FPC bringt das nichts.

creed steiger 11. Feb 2011 15:19

AW: [GNU/Linux, FPC] Linkerproblem bei SO's
 
hilft das weiter?
http://bugs.freepascal.org/view.php?id=12940
http://lists.freepascal.org/lists/fp...er/027228.html

ansonsten würd ich an deiner Stelle mal in der FPC Mailinglist fragen

Assarbad 11. Feb 2011 15:27

AW: [GNU/Linux, FPC] Linkerproblem bei SO's
 
PIC == Position Independent Code

Im Windows-Jargon heißt das "relozierbar". Ob es nun in FPC eine Option dazu gibt, weiß ich nicht.

JamesTKirk 12. Feb 2011 14:59

AW: [GNU/Linux, FPC] Linkerproblem bei SO's
 
Zitat:

Zitat von implementation (Beitrag 1081029)
Das Flag ist aber für gcc, beim FPC bringt das nichts.

*hust*

Code:
[sven@artemis ~]$ fpc -h | grep -i pic
      -Cg       Generate PIC code
  -fPIC Same as -Cg
Und ja, der Schalter funktioniert.

Gruß,
Sven

implementation 13. Feb 2011 15:24

AW: [GNU/Linux, FPC] Linkerproblem bei SO's
 
Es läuft!

Vielen Dank :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz