ANURADHA Srinivasan wrote:
We tried compiling a DLL with the following sources but have not been successful.
program mycall; function add(x:integer;y:integer):integer; far; external 'mylib'; var b:integer; begin b:=add(5,6); end.
library mylib; uses winprocs; function add(x:integer;y:integer):integer;export; begin add:=x+y; end; exports add index 1; begin end.
What changes do we have to make to the sources to build the DLL?
unit mylib;
interface
{ Commented out because I don't have such a unit, but should work the same with it. uses winprocs; }
function add(x:integer;y:integer):integer;
implementation
function add(x:integer;y:integer):integer; begin add:=x+y; end;
begin end.
gpc -shared -o libmylib.so mylib.pas
(Install libmylib.so in a standard lib directory, or set LD_LIBRARY_PATH.)
program mycall; {$L mylib} function add(x:integer;y:integer):integer; external; var b:integer; begin b:=add(5,6); writeln(b) end.
Frank