-qstaticlink

Category

Linking

@PROCESS directive

None.

Purpose

Controls whether static or shared runtime libraries are linked into an application.

This option provides the ability to specify linking rules that are equivalent to those implied by the GNU options -static, -static-libgcc, and -shared-libgcc, used singly and in combination.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-nostaticlink-.                          
>>- -q--+-staticlink---+--+-------------------+----------------><
                          |    .-:----------. |   
                          |    V            | |   
                          '-=----+-libgcc-+-+-'   
                                 '-xllibs-'       

Defaults

-qnostaticlink

Parameters

libgcc
  • When you specify libgcc with nostaticlink, the compiler links the shared version of libgcc.
  • When you specify libgcc with staticlink, the compiler links the static version of libgcc.

This suboption provides the equivalent ability that is enabled by the GNU options -static-libgcc and -shared-libgcc.

xllibs
  • When you specify xllibs with nostaticlink, the compiler links the shared version of the XL compiler libraries.
  • When you specify xllibs with staticlink, the compiler links the static version of the XL compiler libraries.

Usage

When you specify -qstaticlink without suboptions, only static libraries are linked with the object file.

When you specify -qnostaticlink without suboptions, shared libraries are linked with the object file.

Conflicting compiler options are resolved as follows:
  • If you first specify -qnostaticlink without suboptions and then specify -qstaticlink with or without suboptions, -qnostaticlink is overridden. For example, -qnostaticlink -qstaticlink=xllibs is equivalent to -qstaticlink=xllibs.

  • If you specify -qstaticlink with or without suboptions followed by -qnostaticlink without suboptions, -qnostaticlink takes effect and shared libraries are linked. Otherwise, once you have specified -qstaticlink without suboptions, -qstaticlink takes effect and only static libraries are linked with the object file. See the following examples:
    Table 1. Examples of conflicting compiler options and resolutions
    Options combination Compiler behavior
    -qstaticlink=libgcc -qnostaticlink Shared libraries are linked.
    -qstaticlink -qnostaticlink=libgcc All libraries are linked statically. The compiler issues the following warning message:

    (W) The options -qnostaticlink=libgcc and -qstaticlink are incompatible. Option -qnostaticlink=libgcc is ignored.
    -qstaticlink -qnostaticlink=libgcc:xllibs All libraries are linked statically. The compiler issues the following warning messages:

    (W) The options -qnostaticlink=libgcc and -qstaticlink are incompatible. Option -qnostaticlink=libgcc is ignored.

    (W) The options -qnostaticlink=xllibs and -qstaticlink are incompatible. Option -qnostaticlink=xllibs is ignored.
    -qstaticlink -qstaticlink=libgcc All libraries are linked statically.
    -qnostaticlink=libgcc -qstaticlink All libraries are linked statically.
Note: If a runtime library is linked in statically while its message catalog is not installed on the system, messages are issued with message numbers only, and no message text is shown.

Important: Any use of third-party libraries or products is subject to the provisions in their respective licenses. Using the -qstaticlink option can have significant legal consequences for the programs that you compile. It is strongly recommended that you seek legal advice before you use this option.

The following table shows the equivalent GNU and XL Fortran options for specifying linkage of shared and nonshared libraries.
Table 2. Option mappings: control of the GNU linker
GNU option Meaning XL Fortran option
-shared Build a shared object. -qmkshrobj  1 
-static Build a static object and prevent linking with shared libraries. Every library that is linked to must be a static library. -qstaticlink
-shared-libgcc Link with the shared version of libgcc. -qnostaticlink=libgcc  2 
-static-libgcc Link with the static version of libgcc. You can still link your shared libraries. -qstaticlink=libgcc
Notes:
  •  1  Options -qmkshrobj and -qstaticlink are incompatible and cannot be specified together.
  •  2  This is the default setting on SUSE Linux Enterprise Server (SLES) and Red Hat Enterprise Linux (RHEL).

Related information