I cannot get the x11 app to cross-compile on windows to linux :-(
I made another testcase:
fplink.pp
Code:
unit fplink;
interface
function fpLoadLibrary(AName: PChar): Pointer;
function fpFreeLibrary(ALibHandle: Pointer): Boolean;
function fpGetProcAddress(AProcName: PAnsiChar; ALibHandle: Pointer): Pointer;
implementation
const
RTLD_LAZY = $001;
RTLD_NOW = $002;
RTLD_BINDING_MASK = $003;
// Seems to work on Debian / Fedora
LibraryLib = {$IFDEF Linux} 'libdl.so.2'{$ELSE} 'c'{$ENDIF};
function dlopen(Name: PAnsiChar; Flags: LongInt): Pointer; cdecl; external LibraryLib name 'dlopen';
function dlclose(Lib: Pointer): LongInt; cdecl; external LibraryLib name 'dlclose';
function dlsym(Lib: Pointer; Name: PAnsiChar): Pointer; cdecl; external LibraryLib name 'dlsym';
function fpLoadLibrary(AName: PChar): Pointer;
begin
fpLoadLibrary := dlopen(AName, RTLD_LAZY);
end;
function fpFreeLibrary(ALibHandle: Pointer): Boolean;
begin
if ALibHandle = nil then
fpFreeLibrary := False
else
fpFreeLibrary := dlclose(ALibHandle) = 0;
end;
function fpGetProcAddress(AProcName: PAnsiChar; ALibHandle: Pointer): Pointer;
begin
fpGetProcAddress := dlsym(ALibHandle, AProcName);
if fpGetProcAddress <> nil then
exit;
end;
end.
Dont mind the fcgitest all it does is using the functions in fplink.pp
But compiling gives:
Code:
D:\Projecten\i386-linux\fastcgi\test>ppcross386 -TLINUX -gl -FlD:\i386-linux\lib
-XrD:\i386-linux\lib -FL/usr/lib/ld-linux.so.2 -XLAc=c,dl,gmodule fcgitest.pp
Free Pascal Compiler version 2.5.1 [2009/10/24] for i386
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for i386
Compiling fcgitest.pp
Linking fcgitest
fplink.o: In function `FPLINK_FPLOADLIBRARY$PCHAR$$POINTER':
fplink.pp:(.text+0xf): warning: Using 'dlopen' in statically linked applications
requires at runtime the shared libraries from the glibc version used for linkin
g
D:\lib\\libdl.a(dlopen.o): In function `dlopen':
: undefined reference to `__dlopen'
D:\lib\\libdl.a(dlclose.o): In function `dlclose':
: undefined reference to `__dlclose'
D:\lib\\libdl.a(dlsym.o): In function `dlsym':
: undefined reference to `__dlsym'
fcgitest.pp(84,1) Error: Error while linking
fcgitest.pp(84,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Maybe i should give up .
Bookmarks