RE: static initializers do not get run in dylibs with gcc 3.3
RE: static initializers do not get run in dylibs with gcc 3.3
- Subject: RE: static initializers do not get run in dylibs with gcc 3.3
- From: "Jan Hardenbergh" <email@hidden>
- Date: Wed, 8 Dec 2004 07:54:05 -0500
- Thread-topic: static initializers do not get run in dylibs with gcc 3.3
We have a winner!!!
Geoff suggestion of using -single_module works perfectly in my case.
T H A N K Y O U ! ! !
YON - Jan C. Hardenbergh, email@hidden, 978-369-6500x272
Director of VolumePro Software Engineering, TeraRecon, Inc. Concord Office
-----Original Message-----
From: Geoffrey Schmit [mailto:email@hidden]
Sent: Tuesday, December 07, 2004 4:51 PM
To: email@hidden
Cc: Jan Hardenbergh
Subject: RE: static initializers do not get run in dylibs with gcc 3.3
On 07/12/2004 at 8:59 AM, Jan Hardenbergh <email@hidden>
wrote:
> That's a good idea, but, that is not what is happening.
>
> This is a dylib that is registering procedure pointers to be called
> externally, so, understanding who is calliing them is hard.
>
> But, no matter what optimization level I use (-g, -O0, -O2) the
> code is there. If I call hackMyClass(), then magically, the
> constructor for myClass is run. So, the code is there.
>
> The optimization levels do make a difference. The dylib has about
> 25 classes in it. With -O2, no static initializers run. With -O0
> and -g, 9 of the static initializers run.
>
> So, currently, I compile -O0 and call 16 hackMyClass() routines and
> it works.
>
> I'd like to get rid of those 16 calls. It seems like many people
> have run into this problem and there seem to be many piecewise
> solutions.
Try the single_module linker option. It will combine all of your
modules into one when they are linked. As a result, when any function
in your dynamic library is invoked, all static initializers should be
invoked first.
geoff
--
Geoffrey Schmit
Senior Software Engineer
National Instruments
email@hidden
www.ni.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden