Reputation: 13
I am trying to compile the simplest example program of the GNU Scientific Library with the current stable version: GLS-2.8, following the first example in the documentation at example.
The installation of the library was done in the default directories, as the example.
The steps of compilation of the example are:
1 gcc -Wall -I/usr/local/include -c example.c
2 gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm
These procedures worked fine and created the a.ou file, but when the ./a.out command was executed, the following message appears
"./a.out: Error loading shared libraries: libgsl.so.28: Cannot open shared object file: No such file or directory".
Well, in the directory of the library (/usr/local/lib) is the file libgsl.so.28 inside like the others:
libgsl.a
libgslcblas.a
libgsl.so
libgslcblas.so
libgls.so.28
libgsl.so.28.0.0
Why did the linker not find the library? How should I change step 2 of the compilation? Maybe the new version 2.8 needs some modification of the manual or I am missing some step.
I expected the example to work fine since the steps of the example in the manual were followed. I am using gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 under Ubuntu 24.04.
Upvotes: 1
Views: 206
Reputation: 61337
After installing any new shared library you
need to update the runtime linker cache before the runtime linker can find
it in default search (i.e. without you directing the linker to it via LD_LIBRARY_PATH
at runtime).
To do this it should suffice to run:
$ sudo ldconfig
See man ldconfig.
This will update the cache for all the directories listed in /etc/ld.so.conf
and files included therein,
plus /lib
and /usr/lib
.
If by any chance /usr/local/lib
is not specified in /etc/ld.so.conf
or a file that it includes then run:
$ sudo ldconfig /usr/local/lib
Upvotes: 0