Subject: RE: Global constructors in DLL ?
From: [email-masked] (Colin Peters)

12 Aug 1998 05:20:06 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
To: "Edwin Essenius" <[email-masked]>
Cc: "GNU-win32" <[email-masked]>

Edwin Essenius <[email-masked]> 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).

Colin.

P.S. Apologies for being terse.

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".