Sun Studio 12: C++ User's Guide

A.2.149 –xnolib

Disables linking with default system libraries.

Normally (without this option), the C++ compiler links with several system support libraries to support C++ programs. With this option, the -llib options to link the default system support libraries are not passed to ld.

Normally, the compiler links with the system support libraries in the following order:

-lCstd -lCrun -lm -lc

-lC -lm -lc

The order of the -l options is significant. The -lm option must appear before -lc.

Note –

If the -mt compiler option is specified, the compiler normally links with -lthread just before it links with -lm.

To determine which system support libraries will be linked by default, compile with the -dryrun option. For example, the output from the following command:

example% CC -xarch=v9 -dryrun

Includes the following in the output:

-lCstd -lCrun -lm -lc

A.2.149.1 Examples

For minimal compilation to meet the C application binary interface (that is, a C++ program with only C support required), use:

example% CC– xnolib– lc

To link libm statically into a single-threaded application with the generic architecture instruction set, use:

example% CC -xnolib -lCstd -lCrun -Bstatic -lm -Bdynamic -lc

example% CC -compat -xnolib -lC -Bstatic -lm -Bdynamic -lc


Some static system libraries, such as libm.a and libc.a, are not available when linking with -xarch=v9, -xarch=v9a or -xarch=v9b.

If you specify– xnolib, you must manually link all required system support libraries in the given order. You must link the system support libraries last.

If -xnolib is specified, -library is ignored.


Many C++ language features require the use of libC (compatibility mode) or libCrun (standard mode).

This set of system support libraries is not stable and might change from release to release.

See also

–library, –staticlib, –l