Sun Studio 12: C++ User's Guide

A.2.106 –xar

Creates archive libraries.

When building a C++ archive that uses templates, it is necessary in most cases to include in the archive those template functions that are instantiated in the template database. Using this option automatically adds those templates to the archive as needed.

A.2.106.1 Values

Specify -xar to invokes ar -c -r and create an archive from scratch.

Examples

The following command line archives the template functions contained in the library and object files.


example% CC -xar -o libmain.a a.o b.o c.o

Warnings

Do not add .o files from the template database on the command line.

Do not use the ar command directly for building archives. Use CC –xar to ensure that template instantiations are automatically included in the archive.

See also

ar(1), Table 15–3