- publishing free software manuals
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
ISBN 0954612078
RRP £24.95 ($39.95)

Get a printed copy>>>

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 configuration(3) or 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
$ ./example

In the C-shell (/bin/csh or /bin/tcsh) the equivalent command is,

% 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,

$ gcc -static example.o -lgsl -lgslcblas -lm
ISBN 0954612078GNU Scientific Library Reference Manual - Third Edition (v1.12)See the print edition