Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
swimas
|-- etc
|   `-- modulefiles
|       `-- xmllib
|           |-- 4.0-GCC-6.1.0
|           `-- 4.0-intel-17.0.4
`-- extra
    `-- xmllib
        |-- 4.0-GCC-4.8.5
        |   |-- include
        |   |   |-- f90_file_reader.mod
        |   |   |-- mod_f90_kind.mod
        |   |   |-- string_manipulation_tools.mod
        |   |   |-- xml2eg_mdl.mod
        |   |   |-- xml_file_reader.mod
        |   |   |-- xmllib_parser.mod
        |   |   |-- xmllib_pathquery.mod
        |   |   `-- xmllib_types.mod
        |   `-- lib
        |       |-- libxmllib.a
        |       `-- pkgconfig
        |           `-- xmllib.pc
        |-- 4.0-intel-17.0.4
        |   |-- include
        |   |   |-- f90_file_reader.mod
        |   |   |-- mod_f90_kind.mod
        |   |   |-- string_manipulation_tools.mod
        |   |   |-- xml2eg_mdl.mod
        |   |   |-- xml_file_reader.mod
        |   |   |-- xmllib_parser.mod
        |   |   |-- xmllib_pathquery.mod
        |   |   `-- xmllib_types.mod
        |   `-- lib
        |       |-- libxmllib.a
        |       `-- pkgconfig
        |           `-- xmllib.pc
        `-- lib
            |-- libxmllib-4.0-GCC-4.8.5.a -> ../4.0-GCC-4.8.5/lib/libxmllib.a
            `-- libxmllib-4.0-intel-17.0.4.a -> ../4.0-intel-17.0.4/lib/libxmllib.a

RPATH - compiling codes with fixed location of libraries

One of the drawbacks of the module based layout is the problem of pointing to proper library (if we don't have symbolic links with fully qualified names).

This issue can be solved with rpath while compiling the code. Instead of having number of libraries, each with slightly different name, we can use rpath instead.

Code Block
languagebash
gcc -o $@ $< -Iinclude -Llib -lshared -Wl,-rpath,$(CURDIR)/lib

This way, each code will refer to version of library used for linking.

ProsCons
different codes can use different versions of librarieswith each release of new version of the library user's code must be recompiled
each library is released as a separate installation (it's easy to maintain each version separately)it's not possible to move libraries from their original location
we are not forced to build log LD_LIBRARY_PATH variables 
LD_LIBRARY_PATH has lower precedence than rpath 
It is still possible to use LD_PRELOAD to enforce given library to be used (e.g. debugging purposes)