This is the mail archive of the
mailing list for the Cygwin project.
RE: Global constructors in DLL ?
- To: "Edwin Essenius" <edwin at bitbybit-is dot nl>
- Subject: RE: Global constructors in DLL ?
- From: "Colin Peters" <colin at fu dot is dot saga-u dot ac dot jp>
- Date: Wed, 12 Aug 1998 10:00:03 +0900
- Cc: "GNU-win32" <gnu-win32 at cygnus dot com>
Edwin Essenius <email@example.com> wrote:
>I am using cywin B19.2, with the sergey patches an trying to build a
>C++ DLL. Except for the Global constructors all seems to work.
>Global variables in the DLL are initialized, but the global constructors
>are not called when it is declared in a DLL.
If you have written or obtained your own startup code for the DLL (what the
entry point is set to on the link line, or DllMain possibly) then you should
check that you are calling __main in the startup code on DLL_PROCESS_ATTACH.
__do_global_dtors should be called on DLL_PROCESS_DETACH. Also make sure to
disable atexit inside the DLL (mainly for the call to __main) or the main
process may attempt to call your destructors when it exits, which could be
after the DLL has been detached.
See the file dllcrt1.c in the Mingw32 snapshot on my homepage
(www.geocities.com/Tokyo/Towers/6162/gcc.html) for an example of how this
can be done (Note: this doesn't initialize the cygwin library though).
P.S. Apologies for being terse.
For help on using this list (especially unsubscribing), send a message to
"firstname.lastname@example.org" with one line of text: "help".