Static vs Shared Libraries on HPUX
Gcc
gcc@sunburst.rose.hp.com
Thu Nov 13 14:17:00 GMT 1997
I have an application which builds into shared libary. However, it will
always crash when it an application tries to use the shared library.
Although if I create an static library(.a file) and link it into the
application everything runs smoothly. The application will work perfectly
if I take out a static reference to an STL list. However, I prefer not to
because it should be the compiler's job :). This bug exists on all
versions of gcc and egcs. I've heard u can do this __atribute(weak) thing
but I have no idea how.
Sample Code(I'm not sure if this will crash or not I am just writing it
off hand, Although I could provide other examples to prove the point):
crashtest.h
#include <iostream.h>
#include <list>
#include <string>
class CrashTest {
CrashTest();
~CrashTest();
private:
static list <string> crashList;
};
crashtest.cpp
list<string> CrashTest::crashList;
CrashTest::CrashTest() {
cout << crashList.size();
}
I would love to see egcs fix this problem. This bug is a major
hassle on big developmental projects which use STL, templates with shared
libraries.
Kindly Regards,
Sam Yu
More information about the Gcc
mailing list