[fpc-pascal] loadlibrary() unsafe ?
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Fri Jun 12 19:33:03 CEST 2015
fredvs wrote:
> - For [...], the eSpeak source produces a executable without static
> espeak-library nor static portaudio-library included in executable.
> So both espeak-library and portaudio-library must be installed in library
> path of the system.
> If libraries are not installed in library path of the system, a trick that
> works is:
>
> To do run the program =>
> - first dynamic load portaudio with
> loadlibrary('/the_path_you_want/libportaudio.so').
> - then dynamic load libespeak with
> loadlibrary('/the_path_you_want/libespeak.so').
> - run the executable via TProcess (speak).
>
> All is working like charms.
>
> Now i heard that this trick is unsafe.
>
> Why ?
I suspect that the point is that whatever reference counts that the OS
maintains for the library will be decremented if the outer program
terminates, at which point the demand-loaded code will be removed from
memory.
Before trying anything like this, I suggest that it would be worth
finding under what circumstances appropriate symlinks etc. are set up.
--
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