Sun Studio 12: C++ User's Guide

A.2.41 –instlib=filename

Use this option to inhibit the generation of template instances that are duplicated in a library, either shared or static, and the current object. In general, if your program shares large numbers of instances with libraries, try -instlib=filename and see whether compilation time improves.

A.2.41.1 Values:

Use the filename argument to specify the library that you know contains the existing template instances. The filename argument must contain a forward slash ’/’ character. For paths relative to the current directory, use dot-slash ’./’.

Defaults:

The -instlib=filename option has no default and is only used if you specify it. This option can be specified multiple times and accumulates.

Example:

Assume that the libfoo.a and libbar.so libraries instantiate many template instances that are shared with your source file a.cc. Adding -instlib=filename and specifying the libraries helps reduce compile time by avoiding the redundancy.

example% CC -c -instlib=./libfoo.a -instlib=./libbar.so a.cc

Interactions:

When you compile with -g, if the library specified with -instlib=file is not compiled with -g, those template instances will not be debuggable. The workaround is to avoid -instlib=file when you use -g.

Warning

If you specify a library with -instlib, you must link with that library.

See Also:

-template, -instances, -pti