Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Mar 1999 18:54:28 +0000
From:      Niall Smart <nsmart@kira.team400.ie>
To:        Graham Wheeler <gram@cdsec.com>
Cc:        hackers@freebsd.org
Subject:   Re: C++ global constructors and shared libraries
Message-ID:  <36E6BFE4.951172E3@kira.team400.ie>
References:  <36E6AB40.742D64BB@cdsec.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdio.h>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36E6BFE4.951172E3>