[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
system/1394: shared C++ libs not initialized.
>Synopsis: Global constructors of shared libraries are not called.
>Arrival-Date: Thu Sep 7 10:30:01 MDT 2000
>Originator: Carlo Wood
System : OpenBSD 2.7
Machine : i386
Compiler : gcc version 2.95.2 19991024 (release)
A shared C++ library containing global objects is unusable
since the constructors of that library are not called.
It seems that .init is not called, or that .init doesn't
call the needed functions to initialize the global constructors.
This was tested by two different people on two different
machines. The problem first occured to me for a library
created by libtool (which I suppose knows how to create
Create two files:
extern string s;
s = "Hello World";
cout << s << '\n';
Then run the following commands:
setenv LD_LIBRARY_PATH ".:/usr/lib:/usr/local/lib"
g++ -g -fPIC -o global.o -c global.cc
g++ -g -o main.o -c main.cc
ld -Bshareable global.o /usr/lib/c++rt0.o -o libglobal.so.0
g++ main.o -L. -lglobal
This will core dump in "s = "Hello World"" because 's' is