thorp@spudge.UUCP (Don Thorp) (10/19/89)
I've just started using C++ so I still shaky, but I've run into an anomaly that I just can't explain. I've created a couple of classes that use a static instance of the class to ensure that the class is initialized before any other instances are created. Anamoly: It Works ! :-) I link the objects modules directly without placing them in a library. The constructors are called, and everything works fine. It Doesn't Work :-< Using ZorLib, I create libraries containg the object modules. I link them in using MS-Link or BLink and ... the static constructors are never called! Why? Don Thorp USENET: ...!texbell!letni!rwsys!spudge!thorp Phone : (817) 390-2144
bright@Data-IO.COM (Walter Bright) (10/23/89)
In article <4659@spudge.UUCP> thorp@spudge.UUCP (Don Thorp) writes: >Using ZorLib, I create libraries containg the object modules. I link them in >using MS-Link or BLink and ... the static constructors are never called! Why? 1. Try it with MS-LIB. ZORLIB has a lot of bugs in it. 2. Since static constructors are not referenced directly by anything, you need some reference into the .OBJ file containing the static constructor, else it will never be pulled in by the linker. Modules are only pulled in from libraries in response to trying to satisfy unresolved externals. A quick way to test this is to try to link *without* your library. If there are no unresolved externals, there is nothing in the library that is needed, and so nothing is pulled in from it.