-bdynamic, -bshared, and -bstatic

Category

Linking

@PROCESS

None.

Purpose

These options are toggles that are used to control the processing of -l options and the way that shared objects are processed.

The options -bdynamic and -bshared are synonymous.

Syntax

Read syntax diagramSkip visual syntax diagram
   .-bshared--.   
   +-bdynamic-+   
>>-+-bstatic--+------------------------------------------------><

Defaults

-bshared or -bdynamic

Usage

When -bstatic is in effect, shared objects are statically linked into the output file. When -bdynamic is in effect, shared objects are linked dynamically.

When -brtl is used in conjunction with either -bdynamic or -bshared, the search for libraries specified with the -l option is satisfied by the suffix .so or .a. For each directory searched, a file with the suffix .so is looked for. If it is not found, a file with the suffix .a is looked for. If neither file is found, the search continues with the next directory.

Rules

These options are passed directly to the ld command and are not processed by XL Fortran at all.

These options are position-significant and affect all files that are specified after the options on the command-line.

Table 1 summarizes how these options interact with -brtl and -bnortl to affect the file suffix that is being searched.
Table 1. Interaction of linker options
  Position-significant

-bdynamic
-bshared (default)

-bstatic
Global Influence -brtl

.so
.a

.a
-bnortl (default) .a .a

Examples

xlf95 f.f -brtl -bshared -lmylib
In this case, the linker searches for the library libmylib.so first and then the library libmylib.a in each directory in the search path consecutively until either is encountered.
xlf95_r f.f -bdynamic -llib1 -bstatic -llib2 -brtl
In this case, to satisfy the first library specification, the linker searches for the library liblib1.so first and then the library liblib1.a in each directory (as described in the previous example). However, at the same time the linker only searches for liblib2.a in those same directories.

Related information