|GNU Scientific Library Reference Manual - Third Edition (v1.12)|
by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi
Paperback (6"x9"), 592 pages, 60 figures
RRP £24.95 ($39.95)
2.3 Shared Libraries
To run a program linked with the shared version of the library the operating system must be able to locate the corresponding ‘.so’ file at runtime. If the library cannot be found, the following error will occur:
$ ./a.out ./a.out: error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory
To avoid this error, either modify the system dynamic linker
define the shell variable
LD_LIBRARY_PATH to include the
directory where the library is installed.
For example, in the Bourne shell (
the library search path can be set with the following commands:
$ LD_LIBRARY_PATH=/usr/local/lib $ export LD_LIBRARY_PATH $ ./example
In the C-shell (
/bin/tcsh) the equivalent
% setenv LD_LIBRARY_PATH /usr/local/lib
The standard prompt for the C-shell in the example above is the percent character ‘%’, and should not be typed as part of the command.
To save retyping these commands each session they can be placed in an individual or system-wide login file.
To compile a statically linked version of the program, use the
-static flag in
$ gcc -static example.o -lgsl -lgslcblas -lm
|ISBN 0954612078||GNU Scientific Library Reference Manual - Third Edition (v1.12)||See the print edition|