467,136 Members | 1,207 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,136 developers. It's quick & easy.

STL with shared library

S S
Hi

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.

S
Jun 27 '08 #1
  • viewed: 2769
Share:
3 Replies
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.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
S S
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.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thanks for the pointers. But that means, we can never use shared
library with STL ? 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?
Jun 27 '08 #3
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
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Oliver | last post: by
1 post views Thread by Torsten Mueller | last post: by
6 posts views Thread by klh | last post: by
2 posts views Thread by santa19992000@yahoo.com | last post: by
7 posts views Thread by akennis | last post: by
5 posts views Thread by David T. Ashley | last post: by
4 posts views Thread by Nethali | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.