[fpc-other] How to set library search path ?

Giuliano Colla giuliano.colla at fastwebnet.it
Mon Mar 13 00:25:46 CET 2017


Il 12/03/2017 20:15, Fred van Stappen ha scritto:

> But is it possible to set that library path without to edit a file, 
> only by command (via a TProcess) ?
>
>
> And if it is possible for Linux, how to do for Windows and FreeBSD and 
> Mac OS (and other os are welcome).
>
>

If the libraries are needed to run the program, you cannot use a 
TProcess in your application, which would be executed after the loader 
has loaded the program.
What you need is something which tells the loader where to search the 
libraries required by the program.

As far as Linux and FreeBSD are concerned, my suggestion would be that 
you launch your application from a shell script, which does the work.
Sort of an executable file called MyProg.sh (for example) whose content 
would be something like:

#!/bin/sh
mylibpath=/usr/special/lib
export LD_LIBRARY_PATH="$mylibpath:$LD_LIBRARY_PATH"
/Path/to/executable/MyProg

That way the environment variable will be properly set to include your 
specific library path (together with anything else your end user had 
set) before you start the program, and the loader will know where to 
look for libraries.

On Mac Os you could do in principle something similar, but you should 
get advice from those which are familiar with this OS.
On Windows you might use a .bat file, but again you'd need advice from 
Windows users.

Giuliano




More information about the fpc-other mailing list