Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-08

[Linux] Accessing Shared Libraries in *Current* Binary Directory

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

T. Guilleminot

Hi,

For portability reason I would need to keep my shared libraries in the same directory as the binary which need to call them.

As per http://courses.cs.vt.edu/~cs3304/FreePascal/doc/prog/node13.html : "This program can be compiled without any additional command-switches, and should run just like that, provided the library is placed where the system can find it.
For example, on LINUX, this is /usr/lib or any directory listed in the /etc/ld.so.conf file. On WINDOWS, this can be the program directory, the WINDOWS system
directory, or any directoy mentioned in the PATH".

So I would basically need the behaviour of Windows on Linux. Of course I would avoid to have to update ld.so.conf file.
Is there any solution ?

Thanks,
Tom

Reply by email

tom_at_work
to T. Guilleminot

Hello,

T. Guilleminot wrote 21 lines
For portability reason I would need to keep my shared libraries in the same directory as the binary which need to call them. As per http://courses.cs.vt.edu/~cs3304/FreePascal/doc/prog/ node13.html : "This program can be compiled without any additional command- switches, and should run just like that, provided the library is placed where the system can find it. For example, on LINUX, this is /usr/lib or any directory listed in the /etc/ld.so.conf file. On WINDOWS, this can be the program directory, the WINDOWS system directory, or any directoy mentioned in the PATH". So I would basically need the behaviour of Windows on Linux. Of course I would avoid to have to update ld.so.conf file. Is there any solution ?

You may try passing special linker options to the GNU ld linker like described in http://www.eyrie.org/~eagle/notes/rpath.html .

E.g. something like -k"-R ." maybe helps, did never t.

Regards,
Thomas

Reply by email

Alan Krause
to T. Guilleminot: For portability reason I would need to keep my shared libraries in the same directory as…

Tom,

In the bash shell, type in:

export LD_LIBRARY_PATH=.

This appends the current directory to the library search path, so if you cd to the app's directory before executing it, you will be good to go. You could also write a bash script to perform these steps automatically for you, as I know some applications have done in the past.

Alan

T. Guilleminot wrote 18 lines
Hi, For portability reason I would need to keep my shared libraries in the same directory as the binary which need to call them. As per http://courses.cs.vt.edu/~cs3304/FreePascal/doc/prog/node13.html<http://courses.cs.vt.edu/%7Ecs3304/FreePascal/doc/prog/node13.html>: "This program can be compiled without any additional command-switches, and should run just like that, provided the library is placed where the system can find it. For example, on LINUX, this is /usr/lib or any directory listed in the /etc/ld.so.conf file. On WINDOWS, this can be the program directory, the WINDOWS system directory, or any directoy mentioned in the PATH". So I would basically need the behaviour of Windows on Linux. Of course I would avoid to have to update ld.so.conf file. Is there any solution ?

Reply by email