Sun Studio 12: C++ User's Guide

A.2.89 -staticlib=l[,l…]

Indicates which C++ libraries, specified by the -library option (including its defaults), by the -xlang option, and by the -xia option, are to be linked statically.

A.2.89.1 Values

l must be one of the following values.

Table A–20 The -staticlib Values

Value 

Meaning  

[no%]library

[Do not] link library statically. The valid values for library are all the valid values for -library (except %all and %none), all the valid values for -xlang, and interval (to be used in conjunction with -xia).

%all

Statically link all the libraries specified in the -library option, all the libraries specified in the -xlang option, and, if -xia is specified in the command line, the interval libraries.

%none

Link no libraries specified in the -library option and the -xlang option statically. If -xia is specified in the command line, link no interval libraries statically.

Defaults

If –staticlib is not specified, –staticlib=%none is assumed.

Examples

The following command line links libCrun statically because Crun is a default value for –library:


example% CC –staticlib=Crun (correct)

However, the following command line does not link libgc because libgc is not linked unless explicitly specified with the -library option:


example% CC –staticlib=gc (incorrect)

To link libgc statically, use the following command:


example% CC -library=gc -staticlib=gc (correct)

With the following command, the librwtool library is linked dynamically. Because librwtool is not a default library and is not selected using the -library option, -staticlib has no effect:


example% CC -lrwtool -library=iostream \
-staticlib=rwtools7 (incorrect)

This command links the librwtool library statically:


example% CC -library=rwtools7,iostream -staticlib=rwtools7 (correct)

This command will link the Sun Performance Libraries dynamically because -library=sunperf must be used in conjunction with -staticlib=sunperf in order for the -staticlib option to have an effect on the linking of these libraries:


example% CC -xlic_lib=sunperf -staticlib=sunperf (incorrect)
 This command links the Sun Performance Libraries statically:

example% CC -library=sunperf -staticlib=sunperf (correct)

Interactions

This option accumulates instead of overrides.

The -staticlib option only works for the C++ libraries that are selected explicitly with the -xia option, the -xlang option, and the -library option, in addition to the C++ libraries that are selected implicitly by default. In compatibility mode (-compat=[4]), libC is selected by default. In standard mode (the default mode), Cstd and Crun are selected by default.

When using -xarch=v9, -xarch=v9a, or -xarch=v9b (or equivalent 64-bit architecture options), some C++ libraries are not available as static libraries.

Warnings

The set of allowable values for library is not stable and might change from release to release.

When using -xarch=v9, -xarch=v9a, or -xarch=v9b, (or equivalent 64-bit architecture options), some libraries are not available as static libraries.

The options -staticlib=Crun and -staticlib=Cstd do not work on 64-bit Solaris x86 platforms. Sun recommends against linking these libraries statically on any platform. In some cases, static linking can prevent a program from working.

See also

-library, 12.5 Statically Linking Standard Libraries