Sun Studio 12 Update 1: C++ User's Guide

A.2.30.1 Interactions

The following options are passed to the linker if– c (the compile-only option) is not specified:

Warnings

Do not use ld -G to build shared libraries; use CC -G. The CC driver automatically passes several options to ld that are needed for C++.

When you use the -G option, the compiler does not pass any default -l options to ld. If you want the shared library to have a dependency on another shared library, you must pass the necessary -l option on the command line. For example, if you want the shared library to be dependent upon libCrun, you must pass -lCrun on the command line.

See also

-dy, -Kpic, -xcode=pic13, –ztext, ld(1) man page, 16.3 Building Dynamic (Shared) Libraries.