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

A.2.153 –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 foo.cc -xarch=v9 -dryrun

Includes the following in the output:


-lCstd -lCrun -lm -lc

A.2.153.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 test.cc–lc

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

Interactions

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.

Warnings

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