Ricky Corsi wrote:
I have an application that uses a 3D engine library compiled as a
static library called EnRG.lib. My own code is normally compiled
against the MS Visual C implementation of the stl, and everything
works fine.
I wanted to try to link the same code against the stlport. but I get
a lot of linking errors (i report one of those at the end of the
message) and I don't understand why...
The library implementations and declarations differ in rather many
aspects: Although they should be source compatible, it is almost
certain that they are not binary compatible.
could it be because the EnRG lib is compiled with the MS's stl??
Quite likely.
being
it a static lib, shouldn't it incorporate the code it needs and leave
me free to link my own code against the library that I prefer?
No: there can only be one standard library in a program. Actually,
you are even more restricted than you think you are: using a
compiler with a different standard library than the one shipping
with the compiler is not guaranteed to work at all! After all, the
compiler generates code dependant on standard library classes. For
example, 'std::bad_cast' is defined by standard library but the
throw statement is generated by the compiler when you do a
dynamic_cast on a reference. There are things a library implementor
can do to avoid most of the problems. One of the options is to
implement the replacement library in a different namespace than
'std' and then use macro magic to make it appear as if it is in
namespace 'std'. Of course, this means that *both* the original
and the add-on standard library need to be linked! (I think this is
the approach taken by STLPor).
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting