answering my own question: it's the -nostartfiles option thats causing the problem: <snip> This is because the code that calles global constructors is located in the default _init(). So, when you start a C++ program normally linked, first code from _init() calls all global constructors, and then main() is called, so in main() you have all global objects already constructed properly. If you don't execute the default _init(), global constructors are not called. </snip> http://www.mail-archive.com/linux-development-apps@xxxxxxxxxxxxxxxxxxxxxxxxx/msg00514.html now i have to figure out who set this option and why ;) matze El Tue, Mar 29, 2005 at 01:56:47PM +0200 matze ha dit: > hi, > > i'm having a problems with the use of static member variables inside > a dynamic library. > > an example of the problem: > > class OtherClass > { > // ... > }; > > class ThisClass > { > private: > static OtherClass ok; > static int alsoOk; > static std::string error; > }; > > (the static members are instantiated in the .cpp file) > > the code compiles and links, the problem arises when loading the > dynamic library: it's ok to have library interal classes (like > OtherClass) or basic types (like the int) as static members but when > using 'external' classes like std::string or others, the loading of > the library fails. the utility dltest reports the error "undefined > symbol: __dso_handle". > > the system is an amd athlon 1 GHz, running Fedora Core 2, with g++ > version 3.3.3. the compiler options are "-W -Wall -pthread -march=i586 > -ggdb". linking is done with "ld -nostartfiles -shared -o libfoo.so > <objects> -lpthread <project libs>" > > thanks in advance > > matze > -- Insanity: doing the same thing over and over again and expecting different results (Albert Einstein) ( ( ( i ) ) ) http://barcelona.indymedia.org ( ( ( i ) ) ) .''`. using free software / Debian GNU/Linux | http://debian.org : :' : `. `'` gpg --keyserver keys.indymedia.org --recv-keys B9A88F6F `-
Attachment:
signature.asc
Description: Digital signature