2 things:
1) IIRC, if omitted the standard calling convention in FPC is cdecl, not stdcall. You omit the calling convention in your library, but in your calling program you use stdcall
EDIT: OK, you don't pass any parameters, so my point is moot, but i still think it's good habit to use explicit calling conventions that match
2) you're only retrieving the pointer to the procedure, you're not executing it -->
https://wiki.freepascal.org/Lazarus/FPC_LibrariesSee section "Loadlibrary - dynamically loading a dynamic library"
uses ...dynlibs...
procedure UseDLL;
type
TMyFunc=function (aInt:Integer; aStr: string):String; StdCall;
var
MyLibC: TLibHandle= dynlibs.NilHandle;
MyFunc: TMyFunc;
FuncResult: string;
begin
MyLibC := LoadLibrary('libc.' + SharedSuffix);
if MyLibC = dynlibs.NilHandle then Exit; //DLL was not loaded successfully
MyFunc:= TMyFunc(GetProcedureAddress(MyLibC, 'MyFunc');
FuncResult:= MyFunc (5,'Test'); //Executes the function
if MyLibC <> DynLibs.NilHandle then if FreeLibrary(MyLibC) then MyLibC:= DynLibs.NilHandle; //Unload the lib, if already loaded
end;
EDIT2:
3) in your library it's a procedure, but your prototype in your calling program is function?!?!?