HP aC++/HP C A.06.25 Programmer's Guide

library on the link line. If such an object is defined in n shared libraries, it will be
initialized and destructed n times at runtime.
When building the same application with the current default, the libraries are not closed
prior to the final link, and the likelihood of a template symbol being defined in more
than one shared library will increase.
Possible Duplicate Symbols in Archive Libraries
If you have built an archive library using automatic instantiation in HP aC++ A.02.00
or A.01.04 and prior versions, and you rebuild that library using the current
(compile-time) instantiation, it is possible that duplicate symbol problems not apparent
in the prior release will generate errors in the current release.
This is because the current default uses the linker, rather than the assigner, to determine
which object file to pick to satisfy instantiation requests.
For example, when your archive library is linked with an application, library objects
in the link may be different than those used when linking the library in a prior release.
Following are two examples of building an archive library; one built with
+inst_auto/+inst_close (the prior default), and the other built with the current
(compile-time) default:
Building an Archive Library with +inst_auto/+inst_close
Suppose for lib.inst_auto.a, the linker chooses foo2.o to resolve symbol x, and
foo3.o to resolve symbol stack <int>, symbols x, y, and stack <int> are each
resolved with no duplicates.
lib.inst_auto.a
-------------------------------------------------
| foo.o | foo2.o | foo3.o |
| | | stack<int> |
| x | x | y |
| y | | |
-------------------------------------------------
Building an Archive Library with Compile-time Instantiation
Suppose for lib.default.a, the linker chooses foo2.o to resolve symbol x, and
foo.o to resolve symbol stack <int>, symbols x, y, and stack <int> are each
resolved, but now there’s a duplicate definition of symbol x. This will cause a linker
duplicate symbol error. This is really a user error, but was not visible before.
lib.default.a
-------------------------------------------------
| foo.o | foo2.o | foo3.o |
| stack<int> | stack<int> | stack<int> |
| x | x | y |
| y | | |
-------------------------------------------------
178 Using HP aC++ Templates