From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Dalgaard BSA To: Fergus Henderson Cc: Peter Dalgaard BSA , gnu-win32@cygnus.com Subject: Re: mingw32: .exe -> .a import libs for DLLs? Date: Mon, 19 Jan 1998 17:06:00 -0000 Message-id: References: <19980120101010.09761@mundook.cs.mu.OZ.AU> X-SW-Source: 1998-01/msg00440.html Fergus Henderson writes: > For global variables, the import library will contain a > *pointer* to the global variable, i.e. for `zip', the > import library will contain a pointer `__imp_zip', and > in the module that uses it (b.c), you need to have > > #define zip (*__imp_zip) Thanx. I got a note from Colin Peters to the same effect, and by Golly, it works... > > There are some notes on Fergus's page on building DLL's with gnuwin32, > > but quite honestly, I cannot make heads or tails of them... > > The notes on my page don't cover the case of linking a DLL in dynamically > using dlopen() or its Win32 equivalent. But if you have any specific > questions about them, I'd be happy to explain things. Actually, dlopen seems to make things simpler since you don't need to make import libs for the DLLs. Luke Tierney's dl-stuff was never a problem, those routines simply just worked. I've got a sketch of a fairly general Makefile set up. It follows below if you're interested (otherwise just send it to the bit bucket!). You don't need to tell me that it's a bit of a mess - I'm getting a bit rusty on the Makefile business... IMPLIBS=dltest.imp all: dltest.exe a.dll b.dll dltest.exe: dltest.o dlfcn.o dltest.exp gcc -o $@ $^ -lcrtdll dltest.o: ../dltest.c gcc -I../../Win -c ../dltest.c dlfcn.o: ../../Win/dlfcn.c gcc -I../../Win -c ../../Win/dlfcn.c dltest.ex1: dltest.o dlfcn.o gcc -o dltest.ex1 dltest.o dlfcn.o -lcrtdll dltest.def: dltest.ex1 echo EXPORTS > dltest.def nm dltest.ex1 | grep '^........ [TD] _' | sed 's/[^_]*_//' >> dltest.def %.imp: %.def %.ex1 dlltool --dllname $*.exe --def $< --output-lib $@ %.exp: %.def %.ex1 dlltool --dllname $*.exe --def $< --output-exp $@ %.imp: %.def %.dll dlltool --dllname $*.dll --def $< --output-lib $@ %.exp: %.def %.dll dlltool --dllname $*.dll --def $< --output-exp $@ a.o: ../a.c gcc -c $< b.o: ../b.c gcc -c $< dllstub.o: ../dllstub.c gcc -c $< fixup.o: fixup.c gcc -c $< %.def: %.o dllstub.o fixup.o echo EXPORTS > $@ nm $< dllstub.o fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> $@ %.dll %.base %.exp: %.o %.def dllstub.o fixup.o $(IMPLIBS) ld --base-file $*.base --dll -o $@ $< dllstub.o fixup.o $(IMPLIBS) -lcrtdll -e _DllMain@12 dlltool --dllname $*.dll --def $*.def --base-file $*.base --output-exp $*.exp ld --base-file $*.base $*.exp --dll -o $*.dll $*.o dllstub.o fixup.o $(IMPLIBS) -lcrtdll -e _DllMain@12 dlltool --dllname $*.dll --def $*.def --base-file $*.base --output-exp $*.exp ld --base-file $*.base $*.exp --dll -o $*.dll $*.o dllstub.o fixup.o $(IMPLIBS) -lcrtdll -e _DllMain@12 -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request@cygnus.com" with one line of text: "help".