[fpc-pascal] loadlibrary() unsafe ?

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Fri Jun 12 23:42:51 CEST 2015

fredvs wrote:
> @ Ewald and Mark => thanks for answer. ;-)
> Yep, i agree, the process is "exotic" but works so good.
> I have to agree too, following Martin Schreiber way: => export
> LD_PRELOAD=$LIBPORTAUDIO, before to run the executable works too.
> And is maybe safer.
> And do not need dynlibs in uses section.
> And no need to unloadlib().
> So, in short, use loadlibrary() to pre-load a library works but better not
> use it ;-)

The best way would be to first find out what package in the OS installs 
the symlink or files you need, and to document this as a prerequisite.

The next-best way would be to investigate whether the wrapper can set 
LD_LIBRARY_PATH and export this to the loaded program.

The next-next-best way would be LD_PRELOAD, since this potentially has 
path issues of its own.

After that comes the way you first thought of :-)

For problems like this,  man ld.so  is your friend.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list