hello,
i don't know if the following code works under android but it works under ubuntu :
example
1 - create the shared library
library mySumlib;
{$mode objfpc}{$H+}
uses
Classes;
function mySum(int1,int2 :integer): integer; cdecl;
begin
result := int1 + int2 ;
end;
exports
mySum;
end.
compile : a .so is created.
create a project to use the shared lib (my example use statically load library but you can use also l library dynamically load).
program tst_Sharedlib;
{$mode objfpc}{$H+}
uses
Classes,sysutils;
function mySum(int1,int2: integer): integer; external 'mysumlib';
begin
writeln('sharedlib test');
writeln('the result of 323 + 593 is : ' + inttoStr(mySum(323,593)));
end.
don't forget the option :
Compiler Options /Compilation and LinkingEnable setting: "Pass options to linker with "-k", delimiter is space" with this option :
-R ./ to indicate where is the library (path).
Compile and run
result :
sharedlib test
the result of 323 + 593 is : 916