Hello together;
here is an example what I'm trying.
This is the source-Code of my Programm which should load the shard-lib which is created in the second code part.
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,dynlibs
{ you can add units after this };
type TPatrick_Add=function(a,b:integer):integer;
var mylib:TLibHandle = dynlibs.NilHandle;
MyFunc: TPatrick_Add;
result:integer;
begin
Writeln('Hello');
mylib:=LoadLibrary('C:\Users\USERNAME\Desktop\Proba\project1_dll.'+sharedsuffix);
if mylib = dynlibs.NilHandle then Writeln('Problem found')
else begin
Writeln('OK');
MyFunc:=TPatrick_Add(dynlibs.GetProcedureAddress(mylib,'Patrick_Add'));
if MyFunc<>nil then Writeln('Func Found');
//Writeln(MyFunc(1,1));
end;
Writeln(GetLoadErrorStr);
Readln;
end.
This is my shared lib /dll (under Windows):
library project1_dll;
{$mode objfpc}{$H+}
uses
Classes
{ you can add units after this };
function Patrick_Add(a,b:integer):integer;cdecl;export;
begin
Patrick_Add:=a+b;
end;
exports Patrick_Add;
begin
end.
If everything is created under windows every thing runs great! ( See attachment)
if the lib is created under linux (armhf) it is not posible to load the lib. May you see any problems in the code? (Spelling of the path & shared lib is correct).