Subject: Out damn DLL, out... my experience
From: [email-masked] (Joseph F. Garvey)

15 Jan 1998 03:46:57 -0800
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
To: [email-masked]

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.

Getting there was surprisingly difficult... and some of the clues
didn't help.

First some details:

I'm running NT4.0 with service pack 3.

I'm using Cygwin32-b18.

There's a note from [email-masked] (not fu.is.saga.u.ac.jp,
like the help message on the cygnus web site says).

Second, the problem.

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. (Impdef does work... as best I can
tell... it just doesn't help solve the problem though it would help if
the problem was some j-random DLL.)

Next, I unpack the shelltools (from the W32 usertools at cygnus.com).

Run configure. As advertised Cygwin-b18 is self hosting. Took a while,
but it worked. :-) (One atta boy for the developers that got us this
far!) I got the needed configuration files.

Then I built tee.exe (tee). I needed to see what commands were required.

I re-ran the command to link tee, but added a request to link in libcygwin.
It worked. 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, but something still was calling a routine looking for a
DLL, but now a null pointer or empty string was being passed as the name
of the DLL. After a lot of looking, I could find no option or clue to
keep this from happening.

Now to the solution:

What does help solve the problem is Colin Peter's web site. It points
you to MinGW32. This, as you'll read, is a MINimalist Gnu Windows32 set
of tools without Cygwin.dll. I obtained and installed these tools in the
"ming" directory. It wasn't clear to me that there is a "proper" choice.

Next, I created a subdirectory, and pulled all the pieces in. Tee.c,
version.c, getopt.c, getopt1.c, error.c, full-write.c, xmalloc.c...

After a little experimentation I generated the following set of commands
(build.bat):

PATH=i:\ming\bin;%PATH%
SET GCC_EXEC_PREFIX=i:\ming\lib\gcc-lib\
SET LIBRARY_PATH=i:/ming/lib/gcc-lib/i386-cygwin32/egcs-2.90.21;i:/ming/i386-cygwin32/lib;i:/ming/lib
SET C_INCLUDE_PATH=i:/ming/i386-cygwin32/include;i:/ming/include
SET CPLUS_INCLUDE_PATH=i:/ming/include/g++;%C_INCLUDE_PATH%
SET OBJC_INCLUDE_PATH=%C_INCLUDE_PATH%
gcc -I. -I/ming/include/nonansi -c error.c
gcc -I. -I/ming/include/nonansi -c full-write.c
gcc -I. -I/ming/include/nonansi -c getopt.c
gcc -I. -I/ming/include/nonansi -c getopt1.c
gcc -I. -I/ming/include/nonansi -c tee.c
gcc -I. -I/ming/include/nonansi -c version.c
gcc -I. -I/ming/include/nonansi -c xmalloc.c
gcc -o tee.exe error.o full-write.o getopt.o getopt1.o tee.o version.o xmalloc.o

There were only a minor number of problems.

	Some of the files needed for the header files are in the nonansi
	  subdirectory.
	I had to force uid_t to int.
	I had to force size_t to unsigned int.
	Sys_nerr, and sys_nerrlist don't seem to exist in MinGW32, but it
	  was harmless to pretend they didn't exist, and just report all
	  errors as an unrecognized error.

I hope this more specific example and discussion will help all those that
are interested in sharing the output of their programming efforts with
other NT users...  without forcing the other users to load all of Cygwin32.

-- 

Joe Garvey                          IBM PC Co., 67SA/B-201/D115H,
[email-masked]              3039 Cornwallis Rd, RTP, NC, 27709

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