S S wrote:
On Jun 2, 8:23 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
>S S wrote:
>>Are there some known issues using STL with shared library. Recently I
got some crash for which the reason I dont see any, and searching on
goolge shown some such issues with shared library.
If somebody can help ? Thanks in advance.
Yes, there are, IIRC. You need to look in the archives for the
discussions on the subject, I am certain you can find something of
interest. I believe it mostly relates to the fact that some shared
objects (libraries) have their own heap and when objects that have their
own dynamic memory (like std::string or std::vector) are created inside
those libraries, the contents may not be readily accessible outside. To
be entirely honest, I don't remember the exact problems, but I've run
into something like that a couple of times.
The bottom line is however that the issue is not really with STL but
with dynamic linking and having a heap in the shared library.
Thanks for the pointers. But that means, we can never use shared
library with STL ?
No, it means you need to learn about the existing issues and ways to
solve the problems when they present themselves. If driving your car
can cause crashing into a wall, do you stop driving altogether?
After some searching I found that multiple memory
managers can not be together in case of shared libs. But even if I use
static library, we still have multiple memory managers ? So why static
libs do not have problems?
Static libs and dynamic libs are features of your compiler/platform and
not really topical in a language newsgroup, sorry. The differences
between how libraries are linked with the rest of the program dictate
what issues can interfere with the use of the library and how to work
around those issues, but those solutions are not *language specific*,
nor are they platform-independent. AFAIK, static libraries are like
your own code, it's just object modules pulled from a different
repository, while dynamic libraries are totally different kind of code
that your program can call during run-time. So, the difference is not
between a static library and a dynamic library, it's between your code
and the code that resides in a dynamic library and is linked with
dynamically.
I strongly suggest getting familiar with the issues and learning how
memory management works on your platform and what it means to have a
custom "allocator" for your standard container. Utilizing allocators is
a significant part of the whole process of learning to use the Standard
Library, and there are whole books written on the subject. I strongly
encourage you to get yourself a copy of Nicolai Josuttis' "C++ Standard
Library: A Tutorial And a Reference". When you have more specific
questions, come back and ask them.
Good luck!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask