More Cygwin 1.0 CD

Steve Jorgensen steve@khoral.com
Tue Nov 30 23:39:00 GMT 1999


Mumit Khan wrote
>> > 	I've never gotten dllwrap or the gcc set of instructions for
>> > 	creating DLL's to work under B20.1 or 1.0.. I just figured it
>> > 	was yet another stupid artifact of windows dll's.. I'm using
>> > 	a combination calls to nm, dlltool, and ld to create dll, which
>> > 	seems to be working for me.  I can send you a perl script that
>> > 	does the right sequence if you like.
>> 
>> Please post. BTW, dllwrap does nothing more than your perl script, just
>> that it handles a few defaults more intelligently.
>> 
>>   $ dllwrap --dry-run [....]
>> 
>> shows exactly what it's going to do. The -v option shows the actual
>> invocations.

	Yes, I know.  Using --dry-run and looking at the available
	online information was how I figured out how to make my perl
	script work.  :)  I've included the script below..  Enjoy.

	The script below is setup to work in the Khoros make system,
	so you'll have to change the first section for you're environment.
	I've added comments to help explain what I'm doing.   The Khoros
	make rules which call this script install libmylib_stub.a as
	libmylib.a in our dynamic library dir.  The libmylib.dll gets
	installed in the binary dir.

						Steve

----------------createdll.pl-----------------------------------------
eval 'exec perl -S $0 ${1+"$@"}'
                if $runnning_under_some_shell;

#========================================================================
# Program Name: kpacktb - Create a khoros package and cdrom image
#
#      Purpose: This program creates shared library DLL's and stub
#		files for the cygwin environment.
#
#		It's invoked like the following:
#		% createdll.pl mylib
#
#		and it produces:
#
#		libmylib_stub.a and libmylib.dll
#
#    Written By: Steve Jorgensen
#          Date: Oct 30, 1999
#
#========================================================================
#-- This section sets things to work in the Khoros environment should
#-- changed for your environment

$BINARY_NAME = shift @ARGV;  # should be the name of your library without
			     # the lib prefix or any extensions at the end.

exit unless $BINARY_NAME;

chop($KHOROS_LIBDIRS = `kmake echolibdirs`);  # directories where -l's exist

chop($KHOROS_LIBS = `kmake echolibs`); # dependant libraries
$KHOROS_LIBS =~ s/^.*-l${BINARY_NAME}(.*)/$1/;

chop($BDIR = `kmake echobindir`);  # dir to install dll
chop($LDIR = `kmake echolibdir`);  # dir to install stub file.
chop($OBJS= `kmake echoobjs`);     # list of *.o's separated by spaces

#--Boiler plate --
#--Don't change below here--
$BNAME="lib${BINARY_NAME}";
$DLLNAME="${BNAME}.dll";
$LIBDIRS="${KHOROS_LIBDIRS} -L/usr/lib/gcc-lib/i686-cygwin/2.9-cygwin-990830 -L/usr/lib/gcc-lib/i686-cygwin/2.9-cygwin-990830/../../..";
$LIBS= "${KHOROS_LIBS} -lgcc -lcygwin -lkernel32 -ladvapi32 -lshell32 -lgcc";
$LD="ld";
$AS="as";
$EXPFILE="${BNAME}.exp";
$DLLTOOL="dlltool";
$DEFFILE="${BNAME}.def";
$BASEFILE="${BNAME}.base";
$ENTRY= "_cygwin_dll_entry";
$LIBFILE="${BNAME}_stub.a";

#-- Create def file from *.o's
print "echo EXPORTS > ${DEFFILE}\n";
system "echo EXPORTS > ${DEFFILE}";
print "nm ${OBJS} | grep '^........ [TDC] _' | sed 's/[^_]*_//' >> ${DEFFILE}\n";
system "nm ${OBJS} | grep '^........ [TDC] _' | sed 's/[^_]*_//' >> ${DEFFILE}";

#-- Begin magic incantation.  Pray to Bill Gates, and sacrafice a chicken :)
print "${LD} -s --base-file ${BASEFILE} --dll -o ${DLLNAME} ${OBJS} ${LIBDIRS} ${LIBS} -e __cygwin_dll_entry\@12\n";
system "${LD} -s --base-file ${BASEFILE} --dll -o ${DLLNAME} ${OBJS} ${LIBDIRS} ${LIBS} -e __cygwin_dll_entry\@12";
print "${DLLTOOL} --as=${AS} --dllname ${DLLNAME} --def ${DEFFILE} --base-file ${BASEFILE} --output-exp ${EXPFILE}\n";
system "${DLLTOOL} --as=${AS} --dllname ${DLLNAME} --def ${DEFFILE} --base-file ${BASEFILE} --output-exp ${EXPFILE}";
print "${LD} -s --base-file ${BASEFILE} ${EXPFILE} --dll -o ${DLLNAME} ${OBJS} ${LIBDIRS} ${LIBS} -e __cygwin_dll_entry\@12\n";
system "${LD} -s --base-file ${BASEFILE} ${EXPFILE} --dll -o ${DLLNAME} ${OBJS} ${LIBDIRS} ${LIBS} -e __cygwin_dll_entry\@12";
print "${DLLTOOL} --as=${AS} --dllname ${DLLNAME} --def ${DEFFILE} --base-file ${BASEFILE} --output-exp ${EXPFILE}\n";
system "${DLLTOOL} --as=${AS} --dllname ${DLLNAME} --def ${DEFFILE} --base-file ${BASEFILE} --output-exp ${EXPFILE}";
print "${LD} ${EXPFILE} --dll -o ${DLLNAME} ${OBJS} ${LIBDIRS} ${LIBS} -e __cygwin_dll_entry\@12\n";
system "${LD} ${EXPFILE} --dll -o ${DLLNAME} ${OBJS} ${LIBDIRS} ${LIBS} -e __cygwin_dll_entry\@12";
print "${DLLTOOL} --as=${AS} --dllname ${DLLNAME} --def ${DEFFILE} --output-lib ${LIBFILE}\n";
system "${DLLTOOL} --as=${AS} --dllname ${DLLNAME} --def ${DEFFILE} --output-lib ${LIBFILE}";
exit 0;
----------------createdll.pl-----------------------------------------

-- 
-----------------------------------------------------------
Steven Jorgensen      steve@khoral.com	    steve@haunt.com
------------------------------+----------------------------
Khoral Research Inc.          | PHONE: (505) 837-6500
6200 Uptown Blvd, Suite 200   | FAX:   (505) 881-3842
Albuquerque, NM 87110         | URL: http://www.khoral.com/
-----------------------------------------------------------

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list