delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/01/21/11:31:45

From: p DOT dalgaard AT biostat DOT ku DOT dk (Peter Dalgaard BSA)
Subject: Re: mingw32: .exe -> .a import libs for DLLs?
21 Jan 1998 11:31:45 -0800 :
Message-ID: <x27m7wc5ic.fsf.cygnus.gnu-win32@blueberry.kubism.ku.dk>
References: <x2ra66c3g4 DOT fsf AT blueberry DOT kubism DOT ku DOT dk>
Mime-Version: 1.0
To: Fergus Henderson <fjh AT cs DOT mu DOT OZ DOT AU>
Cc: Peter Dalgaard BSA <p DOT dalgaard AT biostat DOT ku DOT dk>, gnu-win32 AT cygnus DOT com

Fergus Henderson <fjh AT cs DOT mu DOT OZ DOT AU> 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 AT 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 AT 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 AT 12
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p DOT dalgaard AT biostat DOT ku DOT dk)             FAX: (+45) 35327907

-
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