| GNU Scientific Library Reference Manual - Revised Second Edition (v1.8) by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, M. Booth, F. Rossi Paperback (6"x9"), 636 pages, 60 figures ISBN 0954161734 RRP £24.99 ($39.99) |
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, define the shell variable LD_LIBRARY_PATH to
include the directory where the library is installed.
For example, in the Bourne shell (/bin/sh or /bin/bash),
the library search path can be set with the following commands:
$ LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH $ export LD_LIBRARY_PATH $ ./example
In the C-shell (/bin/csh or /bin/tcsh) the equivalent
command is,
% setenv LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
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 should 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,
$ gcc -static example.o -lgsl -lgslcblas -lm
For more information about trouble-shooting compilation and linking problems, see the book An Introduction to GCC listed in the appendix section Other books from the publisher.
| ISBN 0954161734 | GNU Scientific Library Reference Manual - Revised Second Edition (v1.8) | See the print edition |