Linker input and output files
The linker takes object files, links them with each other and with any library files that you specify, and produces an executable output file. The executable output can be either an executable program file or a shared object.
- Options
- Object files (*.o)
- Archive library files (*.a)
- Dynamic library files (*.so)
- Executable file (a.out by default)
- Shared object
- Return code
Library files: Libraries are
files that have suffix .a or .so. To designate a library, you can
specify an absolute or relative path name or use the -l
(lowercase
letter L) option in the form -lname
.
The last form designates file libname.a, or in
dynamic mode, file libname.so, to be searched for
in several directories. These search directories include directories
that you specify by using -L
options, and the standard
library directories /usr/lib and /lib.
The environment variable LD_LIBRARY_PATH is not used to search for libraries that you specify on the command line
either explicitly (for example, libc.a
) or by using the -l
option
(for example, -lc
). You must use -Ldir
options
to indicate the directories to be searched for libraries that you specified with a
-l
option.
You can create library files by combining one or more files into a single archive file by using
the Linux®
ar
command.