-l

Category

Linking

@PROCESS

None.

Purpose

Searches for the specified library file. For static and dynamic linking, the linker searches for libkey.a. For runtime linking with the -brtl option, the linker searches for libkey.so, and then libkey.a if libkey.so is not found.

Syntax

Read syntax diagramSkip visual syntax diagram
>>- -l--key----------------------------------------------------><

Defaults

The compiler default is to search only for some of the compiler runtime libraries. The default configuration file specifies the default library names to search for with the -l compiler option, and the default search path for libraries with the -L compiler option.

Parameters

key
The name of the library minus the lib and .a or .so characters.

Rules

This option is passed directly to the ld command and is not processed by XL Fortran at all.

Examples

To compile myprogram.f and link it with library libmylibrary.a that is found in the /usr/mylibdir directory, enter the following command:
xlc myprogram.f -lmylibrary -L/usr/mylibdir
To compile myrtprogram.f and link it with library libmyrtlibrary.so, enter the following command. The libmyrtlibrary.so library has been compiled for runtime linking via the -G option and located in the /usr/mylibdir directory.
xlc -brtl myrtprogram.f -lmyrtlibrary -L/usr/mylibdir


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us