delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/01/17/01:26:23

From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson)
Subject: Re: Out damn DLL, out... my experience
17 Jan 1998 01:26:23 -0800 :
Message-ID: <19980116023554.46503.cygnus.gnu-win32@mundook.cs.mu.OZ.AU>
References: <199801132324 DOT SAA00433 AT garveys DOT raleigh DOT ibm DOT com>
Mime-Version: 1.0
To: garvey AT raleigh DOT ibm DOT com
Cc: gnu-win32 AT cygnus DOT com

On 13-Jan-1998, Joseph F. Garvey <garvey AT raleigh DOT ibm DOT com> wrote:
> I had a simple desire. I wanted a tee.exe for NT, that consisted of
> one file, so that it could be copied from system to system in a mindless
> fashion. [...]
> If you have tee.exe (as distributed), you also need cygwin.dll.
> 
> How do I get rid of cygwin.dll? Colin Peter's note says:
> 
> # Steps to generate a libcygwin.a.
> impdef foo.dll > foo.def            #impdef comes from colin's web site.
> dlltool --def foo.def --output-lib libfoo.a
> 
> # Step to use libcygwin.a.
> gcc -o bar.exe bar.o -lfoo
> 
> Well, a libcygwin already exists.
> So, I can link that in and solve the problem without impdef or dlltool.

Nope.  The libcygwin.a that comes with the gnu-win32 distribution is
not a stand-alone library, it is just a stub library that contains
stubs that call cygwin.dll.  The libcygwin.a that you would obtain
using impdef and dlltool as shown above would be the same.

> I re-ran the command to link tee, but added a request to link in libcygwin.
> It worked.

Nope, it didn't.  It just *appeared* to work.
As noted previously on this list, libcygwin is linked in by default.
By linking in libcygwin explicitly, you cause it to be linked in twice.
This results in the various DLL import tables not being properly
terminated or something like that.

> Now I had a tee.exe. When I ran this tee.exe, I ended up with
> an error message "(null)" DLL not found on DLLPATH. Argggggh. Obviously,
> it had linked ok,

No.

> but something still was calling a routine looking for a DLL,

Yes.

> but now a null pointer or empty string was being passed as the name
> of the DLL.

Yes.  That's because it didn't link correctly; probably the executable's
list of DLLs is not properly terminated or something like that.

> After a lot of looking, I could find no option or clue to
> keep this from happening.

You'd need to create a libcygwin.a that was not a stub library.
This would be a fair bit of work; I think some of the code
in cygwin.dll may assume that it is running in a DLL, and may
not work if it is not.

-- 
Fergus Henderson <fjh AT cs DOT mu DOT oz DOT au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3         |     -- the last words of T. S. Garp.
-
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".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019