Lahey/GNU Fortran

Linking

Linking an application is facilitated under the control of the LGF driver. Linking will occur automatically, as long as the -c option is not specified.

The linker reads individual object files and libraries, resolves references to external symbols, and writes out a single executable file or dynamic link library. The linker can also create a map file containing information about the segments and public symbols in the program.

Linking Object files

Object files are processed in the order in which they appear on the command line. Specify the full path if not in the current directory.

Linking Module objects

An object file that is created when compiling a module is treated like any other object file. When linking a program that uses a module, the module's object file must be provided to the linker along with the rest of the program. This can be done in one of several ways:

Linking Libraries

To specify an archive/library to be linked, use -lib, or simply specify a file with the .a extension. Those specified with -lib will be checked for GFortran naming conformity.

If a library file is specified without path information, the linker looks for it in the following order:

  1. In the current working directory
  2. In any directories specified with -libpath.

Additional Linker Options

In addition to the LGF link options, to send specific option(s) to the GNU linker, specify -Wl,<options> to pass comma-separated <options> on to the linker, Note that some linker options will not necessarily apply to Fortran objects.