Dll initializing

root root@jacob.remcomp.fr
Fri Jan 30 16:05:00 GMT 1998

> The reason for this is that cygwin.dll is not initialised. In a cygnus
> gnu-win32 compiled application this is done by the C runtime startup code.
> I started looking at the dll_crt0_1 routine in the
> winsup source of the latest Coolview.
> dll_crt0_1 is the part of the runtime startup done in cygwin.dll.
> A lot of things are done there: initialisation of heap
> (needed by malloc() and friends), initialisation of file I/O (connecting
> to Win32 filemap), etc. All these inits are not done in our scenario.
> It is a pity that all these init routines are not in the exported
> interface of cygwin.dll, so I do not know (yet) how to do them from
> our sample.dll.
All dlls in win32 will be called with an argument indicating that they
are being called for a process, for a thread, for thread termination and for
process termination. I wouldn't believe that the guys in cygnus were so
ignorant, so I suppose the error is elsewhere. What makes me suspicious is
that you say the C runtime calls the dll. In that case the solution is
very simple:
When win32 calls the dll (before your program even runs and is loaded)
just call the initialization functions. Then cygwin will work without any
problems. Do per thread initialization when win32 tells you that a thread is
starting, and per process init, when a process is started.

But this i *SO* basic stuff (many books explain this in great detail!)
that I believe the error must be somewhere else...

Generating dlls is a tricky stuff. I did it for lcc-win32 and you get
horrible complications because (precisely) of this: my first versions
had the same problem like cygnus now, till I discovered that I couldn't  
let the user write the real LibMain, but *I* had to generate a  default 
LibMain that would make the initialization of my C runtime 
and *then* call the user's LibMain with  the same
arguments I received... Kind of tricky specially when you consider
that the user also can have a LibMain... That part of my linker was real

Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01
93430 Villetaneuse 			Fax 01
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

More information about the Cygwin mailing list