From: colin AT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters) Subject: RE: Global constructors in DLL ? 12 Aug 1998 05:20:06 -0700 Message-ID: <004c01bdc58c$8a3ba560$fa173185.cygnus.gnu-win32@gbird0.fu.is.saga-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit To: "Edwin Essenius" Cc: "GNU-win32" Edwin Essenius 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 "gnu-win32-request AT cygnus DOT com" with one line of text: "help".