-L

Category

Linking

Pragma equivalent

None.

Purpose

Searches the directory path for library files specified by the -l option.

Syntax

Read syntax diagramSkip visual syntax diagram
>>- -L--directory_path-----------------------------------------><

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.

For more information, refer to the ld documentation for your operating system.

Predefined macros

None.

Examples

To compile myprogram.c so that the directory /usr/tmp/old is searched for the library libspfiles.a, enter:
xlc myprogram.c -lspfiles -L/usr/tmp/old

Related information