Penguin

InNeedOfRefactor

Where can I set paths to the directories my shared libraries are stored in?

The list of directories to be searched is stored in the file /etc/ld.so.conf. Simply append your desired directory to this file.

  • echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf

Now run ldconfig -v

Note: Don't do this for Gentoo. That already has /usr/local/lib included, and in any case /etc/ld.so.conf is automatically generated from the files in /etc/env.d, so any customizations you want must be made in the latter.

Note : ldconfig(8) must be run whenever a DLL is added, when a DLL is removed, or when the set of DLL directories changes

Which libraries is my system aware of?

  • ldconfig -Nv

Environment Variables

LD_LIBRARY_PATH

A colon-separated set of directories where libraries should be searched for first, before the standard set of directories.

  • export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/new/dir/to/add"

LDLIBS

Contains a list of external libraries to link with.

For example to link with the libtrace library and the math library:

  • export LDLIBS="-ltrace -lm"

How to define macros inside the gcc command.

gcc -D<macro_name>=<definition>

Note : The =<definition> part is optional.

For example:

  • gcc -DEVENT_DEBUG=1

See also SharedLibraryNotes