Hello.

I'm trying to link a DLL dynamicly but I get some errors compiling with FPC, Delphi seems to work right. First I tried this (simplified):[pascal]UNIT example;

INTERFACE
the_function: FUNCTION (arg1, arg2: INTEGER): INTEGER; CDECL;

IMPLEMENTATION

USES
UnitBase, { This unit loads the library at INITIALIZATION section. }
dynlibs;

INITIALIZATION
IF the_shared_library <> NilHandler THEN
the_function := GetProcedureAddress (the_shared_library, 'the_function');

FINALIZATION

END.[/pascal] This compiles on Delphi (with some hacks at "UnitBase" to keep compatibility) but on FPC it shows an error message telling that "have POINTER but FUNCTION (blah blah) expected" or similar.

Then I look at the GL.pas sources and I modified the INITIALIZATION section to[pascal]
INITIALIZATION
IF the_shared_library <> NilHandler THEN
@the_function := GetProcedureAddress (the_shared_library, 'the_function');[/pascal] which also compiles on Delphi but FPC returns "Can't assign a value to an address" but my OpenGL programs compiles and runs right both Linux and Windows. :?

How do I load a DLL/so/dylib dynamicaly?

Note that I haven't Internet connection at home so I did wrote all this by memory.