With the external instances method, all instances are placed within the template repository. The compiler ensures that exactly one consistent template instance exists; instances are neither undefined nor multiply defined. Templates are reinstantiated only when necessary.
Template instances receive global linkage in the repository. Instances are referenced from the current compilation unit with external linkage.
Specify external linkage with the -instances=extern option (the default option).
Because instances are stored within the template repository, you must use the CC command to link C++ objects that use external instances into programs.
If you wish to create a library that contains all template instances that it uses, use the CC command with the -xar option. Do not use the ar command. For example:
%demo CC -xar -o libmain.a a.o b.o c.o
See Chapter 6, Building Libraries for more information.