This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
Re: AW: Linking Dynamic Libraries
- To: Jürgen Schuck <Juergen dot Schuck at materna dot de>
- Subject: Re: AW: Linking Dynamic Libraries
- From: "Charles S. Wilson" <cwilson at ece dot gatech dot edu>
- Date: Mon, 09 Oct 2000 09:45:44 -0400
- CC: michal karczmarek <michal at karczma dot net>, cygwin at sourceware dot cygnus dot com
- References: <004501c031f0$10478ad0$0d33028b@zapperlot.materna.de>
There's an easier way -- one command! 'gcc -shared' will create a dll
for you. Just do:
$(BASE)=foo
gcc -shared -o cyg$(BASE).dll -Wl,--out-implib=lib$(BASE).dll.a \
-Wl,--export-all -Wl,--enable-auto-image-base \
-Wl,--output-def=cyg$(BASE).def $(OBJS)
Grab any of the packages in the 'contrib' directory and look an the
makefiles (you might need to do a minimal 'configure' first, to
customize the Makefile for cygwin before using it as a model)
--Chuck
Jürgen Schuck wrote:
>
> I'm not sure about the kind of object that 'gcc -shared'
> produces. But I think it won't be what you might expect.
> In Windows shared sobjects are DLL's. You probably will
> have to convert your Makefiles to cproduce DLL's instead
> of UNIX-style .so files.
>
> I did the same task when porting a TCL-extension from
> UNIX to Cygwin. The Makefile (SVR4) changes from
>
> libTclDM20.so:
> ld -G -o $@ $(OBJS)
>
> to
>
> LOAD = TclDM20
> DEF = $(LOAD).def
> BAS = $(LOAD).base
> EXP = $(LOAD).exp
> $(DLL): $(OBJS)
> echo EXPORTS >$(DEF)
> nm $+ | grep '^........ [T] _' | sed 's/[^_]*_//' >>$(DEF)
> $(LD) --base-file $(BAS) -dll -o $@ $+ -e _dll_entry@12 \
> -L`dirname \`gcc -print-file-name=libgcc.a\`` \
> $(LIBS) -lgcc -lcygwin -lkernel32 -lgcc
> dlltool --as=as -dllname $@ --def $(DEF) \
> --base-file $(BAS) --output-exp $(EXP)
> $(LD) --base-file $(BAS) $(EXP) -dll -o $@ $+ -e _dll_entry@12 \
> -L`dirname \`gcc -print-file-name=libgcc.a\`` \
> $(LIBS) -lgcc -lcygwin -lkernel32 -lgcc
> dlltool --as=as -dllname $@ --def $(DEF) \
> --base-file $(BAS) --output-exp $(EXP)
> $(LD) $(EXP) -dll -o $@ $+ -e _dll_entry@12 \
> -L`dirname \`gcc -print-file-name=libgcc.a\`` \
> $(LIBS) -lgcc -lcygwin -lkernel32 -lgcc
>
> For further information see
> http://sources.redhat.com/cygwin/docs.html,
> section "Writing DLLs". Reading these docs you
> will find two further modules: dll_init.c and
> dll_fixup.c. I didn't put them into my DLL because
> the resulting DLL crashes the TCL-interpreter.
>
> Furthermore I found it very helpful to take a
> look into the Makefiles of the DLL-generating
> packages of the Cygwin-distribution: tcl, wish
> and tix.
>
> Jürgen Schuck
> PCM-Kundenbetreuung
> Business Unit Information
> _________________________________________________
> MATERNA GmbH Information & Communications
> Vosskuhle 37 * 44141 Dortmund
> Tel.: 0231 - 5599 - 191 * Fax: -272
> Handy: 0172 - 23 70 148 * http://www.materna.de
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com