|
|
C++: Using STL in a library and I get link errors from it - Now what? |
I'm building a static library and the link errors seem to reference things
from the STL that were used in the library - what gives ?
One possibility is that the necessary instantiations weren't done when
you formed your library. Try using the "CC -Tprelink_objects" command on
the .o's that go into the library, before doing the "ar" step that forms
its archive. Like this:
CC -c a.C b.C c.C
CC -Tprelink_objects a.o b.o c.o
ar rv libfoo.a a.o b.o c.o
I can't be sure this will solve your problem but it's the first thing
to try.
Diagnostics coming out of STL are legendary for being hard to understand ...
hops@sco.com | |
| The above CC -Tprelink_objects step is generally necessary when preparing
an archive that contains internal template instantiations. There is a known problem in doing this. If multiple archives are being linked against, it is quite possible that you will get multiple definition errors coming from common template instantiations occurring in multiple .o files. We are currently working on a solution for this problem in our next release. For work-arounds, you either have to restructure your source files, or build with CC -Tlocal (which will blow up object sizes significantly). jls@sco.com | |
| [Append to This Answer] |
| ||||||||