Sun Studio 12: C++ User's Guide

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)