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?