-L
Purpose
Searches the directory path for library files specified by the -l option.
Syntax
Defaults
The default is to search only the standard directories. See the compiler configuration file for the directories that are set by default.
Parameters
- directory_path
- The path for the directory which should be searched for library files.
Usage
When you link shared libraries into an executable, specifying the paths to the libraries with the -L option during the link also embeds the path information in the executable, so the shared libraries can be correctly located at run time. If you do not specify any paths with -L during this link and you additionally prevent the compiler from automatically passing -L arguments to the linker by using the -bnolibpath linker option, only paths that are specified by the LIBPATH environment variable are embedded in the executable file.
If the -Ldirectory option is specified both in the configuration file and on the command line, search paths specified in the configuration file are the first to be searched.
The -L compiler option is cumulative. Subsequent occurrences of -L on the command line do not replace, but add to, any directory paths specified by earlier occurrences of -L.
For more information, refer to the ld documentation for your operating system.
Predefined macros
None.
Examples
myprogram.c
so
that the directory /usr/tmp/old
is searched for the library libspfiles.a
, enter:
ibm-clang myprogram.c -lspfiles -L/usr/tmp/old