Ceci est une ancienne révision du document !
Cette page n'est pas encore traduite entièrement. Merci de terminer la traduction
(supprimez ce paragraphe une fois la traduction terminée)
Example with the library HDF5 in version 1.8.9
In the subdirectory lib
of the installation directory /softs/Hdf5/1.8.9/gnu/4.6.3
, the library is available statically and dynamically. :
ls /softs/Hdf5/1.8.9/gnu/4.6.3/lib libhdf5.a libhdf5.so ...
Whether static or dynamic, to use this library, when editing links (compilation step), you have to add :
-L/softs/Hdf5/1.8.9/gnu/4.6.3/lib -lhdf5
By default, it is the dynamic version that is first searched for when editing links. In this case, at program execution (e.g. on nodes), the variable LD_LIBRARY_PATH
should contain the path of the dynamic library. To do this, add this line in the execution script :
setenv LD_LIBRARY_PATH "/softs/Hdf5/1.8.9/gnu/4.6.3/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/softs/Hdf5/1.8.9/gnu/4.6.3/lib:$LD_LIBRARY_PATH"
To link with the static version, use the -static
option. Example :
gcc ... -static ... -L/softs/Hdf5/1.8.9/gnu/4.6.3/lib -lhdf5 ...
Using the -static
option implies to link all libraries statically. For only the desired library (here libhdf5) to be linked statically, use the full name of the library :
gcc ... -static ... -L/softs/Hdf5/1.8.9/gnu/4.6.3/lib/libhdf5.a ...
The above discussion arises only if both versions (static and dynamic) are installed (as for HDF5). If for another library only one of the versions (static or dynamic) is installed, just add -L/répertoire_de_recherche -lnom_librairie
to link with libnom_librairie.a
(or libnom_librairie.so
).