From owner-freebsd-hackers Wed Mar 10 10:53:31 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from relay02.indigo.ie (relay02.indigo.ie [194.125.133.226]) by hub.freebsd.org (Postfix) with SMTP id 7E36014E22 for ; Wed, 10 Mar 1999 10:53:05 -0800 (PST) (envelope-from nsmart@kira.team400.ie) Received: (qmail 14792 messnum 46199 invoked from network[194.125.148.182/ts04-052.dublin.indigo.ie]); 10 Mar 1999 18:52:46 -0000 Received: from ts04-052.dublin.indigo.ie (HELO kira.team400.ie) (194.125.148.182) by relay02.indigo.ie (qp 14792) with SMTP; 10 Mar 1999 18:52:46 -0000 Message-ID: <36E6BFE4.951172E3@kira.team400.ie> Date: Wed, 10 Mar 1999 18:54:28 +0000 From: Niall Smart Organization: Trinity Commerce X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 3.1-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: Graham Wheeler Cc: hackers@freebsd.org Subject: Re: C++ global constructors and shared libraries References: <36E6AB40.742D64BB@cdsec.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Graham Wheeler wrote: > > Hi folks > > I have just changed some C++ code libraries from static to shared. > I now find that some global objects declared in these libraries > are no longer having their constructors called. If I move the object niall% g++ -v cc -v gcc version 2.7.2.1 niall% g++ -c -fpic libfoo.cc niall% g++ -shared libfoo.o -o libfoo.so niall% g++ main.cc -Wl,-R,. -L. -lfoo niall% ./a.out foo niall% cat libfoo.cc #include struct foo { foo() { printf("%s\n", "foo"); } }; foo f; niall% cat main.cc int main() { } niall% uname -a FreeBSD niall.boi.ie 3.1-STABLE FreeBSD 3.1-STABLE #1: Sat Feb 27 15:18:27 GMT 1999 niall@niall.boi.ie:/usr/src/sys/compile/NIALL i386 Regards, Niall To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message