How do I use the shared libraries on the Linux CLSE?


Shared libraries are vital to the proper function and development of software within the CAEN environment. This document serves to provide a general overview of the key fundamentals of shared libraries and the applications at CAEN that use them.

Locations and Shortcuts

CAEN provides a number of shared libraries for users to compile and develop their own applications. These include jpeg, zlib, and many others. In general, most library packages have two main components: header files and libraries. At CAEN, the header files are generally kept in:


and the libraries are generally kept in:


where app represents the name of the application, and x & y represent the version number. You should check these directories if you are looking for a specific file because CAEN often extra libraries in these locations.


Linking and Using Environment Variables

Name: Usage/Application - Example

  • LD_LIBRARY_PATH: Specifies library location (runtime) - export LD_LIBRARY_PATH="/usr/lib64"
  • LD_RUN_PATH: Specifies library location (compile) - export LD_RUN_PATH="/usr/lib64"

Compiler Switches

Name: Usage/Application - Example

  • -I: - Header file search path - -I/usr/include
  • -L: - Library search path - -L/usr/lib64
  • -R: - Library search path - -R/usr/lib64
  • -l: -Library to link - -llibfoo


  • % cc -I/usr/include -L/usr/lib64 -R/usr/lib64 program.c -o program -lglib
  • % cc -I/usr/include -L/usr/lib64 -Wl,+b,/usr/lib64 program.c -o program -lglib
  • % export LD_RUN_PATH="/usr/lib64"
  • % cc -I/usr/include -L/usr/lib64 program.c -o program -lglib

Search Paths

The search paths must usually include the "system search path," or the location where the system normally looks for libraries. This is indicated in the search path by an empty entry in the colon-separated list of directories. For example, in the LD_LIBRARY_PATH example above, the system paths are searched before /usr/lib64/. Search paths for a given binary may be examined with the ldd and/or chatr commands. You can use these to test how changing environment variables or compilation options will affect your environment. For example:

% ldd /usr/bin/gvim

[...] =&&&&&> /usr/lib64/ =&&&&&> /usr/lib64/


This means that the gvim binary will use the gmodule and glib libraries located in /usr/lib64/glib-2.0/. If instead not found is listed for any of the libraries and/or your application will not run with a similar error, you will need to adjust your environment variables or recompile appropriately.


Usage in Scripts

If you need to reuse these variables, or are using automated build tools to develop software, there are a number of environment variables that are typically used to store and retrieve these settings:

Name: Usage - Example

  • CFLAGS: Compiler flags - export CFLAGS="-I/usr/include -O3"
  • CPPFLAGS: Preprocessor flags - export CPPFLAGS="-I/usr/include"
  • LDFLAGS: Linker flags - export LDFLAGS="-L/usr/lib64"

Further Information

There is a wealth of information available online for CAEN users. Since these options and details are so platform-dependent, the best resource is to read the man pages for the compiler ( man cc or man gcc) and linker (man ld) if you run into problems.



Article ID: 5059
Mon 5/3/21 4:36 PM
Wed 7/19/23 7:45 AM