[fpc-pascal] [HOW TO] Create a shared object (SO) with FP

ik idokan at gmail.com
Fri Apr 22 20:19:40 CEST 2011


On Fri, Apr 22, 2011 at 19:31, Jilani Khaldi <jilani at cheapnet.it> wrote:

> {$linklib c}
>
> uses
>  dynlibs;
>
> procedure hello(const x: double); cdecl; external 'libmylib.so';
>
> var
>  lHandle: TLibHandle;
>  v: double;
> begin
>  lHandle := LoadLibrary('./libmylib.so');
>  if lHandle <> nilHandle then
>  begin
>    v := 3.14159;
>    hello(v);
>  end else
>    writeln('Cannot load "mylib.so"')
> end.
>
> It is compiled without error but when I run it it throws:
> ./testlib: error while loading shared libraries: libmylib.so: cannot open
> shared object file: No such file or directory.
>
> What I did I miss?.
>

You do not have the  library path on the system LD_LIBRARY_PATH variable or
at the ldconfig path.

BTW, why don't you load it dynamically instead of statically if you are
going the next mile to test it.
Your program will not be executed if the library is not found either way...


> Thank you.
>
> --
> Jilani KHALDI
> ** Architectura Vindex
> http://www.vindexa.org
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


Ido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110422/1489e1db/attachment.html>


More information about the fpc-pascal mailing list