Oracle Solaris Studio 12.2:C++ 用户指南

示例

以下命令行静态链接 libCrun,因为 Crun–library 的缺省值:


example% CC –staticlib=Crun (correct)

但以下命令行并不链接 libgc,因为只有使用 -library 选项显式指定才链接 libgc


example% CC –staticlib=gc (incorrect)

要静态链接 libgc,请使用以下命令:


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

以下命令会动态链接 librwtool 库。因为 librwtool 不是缺省库且未使用 -library 选项选择它,因此 -staticlib 不起作用:


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

该命令静态链接 librwtool 库:


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

该命令将动态链接 Sun 性能库,因为 -library=sunperf 必须与 -staticlib=sunperf 结合使用,-staticlib 选项才能对这些库的链接有效:


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

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