[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiling DLLs
From: |
Robert Heller |
Subject: |
Re: Compiling DLLs |
Date: |
Sun, 16 Jan 2005 00:03:48 +0100 |
Eilmsteiner Reinhard <webstuff@eilm.at>,
In a message on Sat, 15 Jan 2005 22:10:15 +0100, wrote :
ER> Hello!
ER>
ER> I've been using g++ a lot on Linux.
ER> But now I need to compile a MS-Windows DLL... and I have cygwin installed.
ER>
ER> Is there a way to compile a Windows library (DLL) with g++?
ER> Do DLLs created that way depend on cygwin? If yes, how can I get rid of
ER> this dependency?
ER> How do I tell g++ (or the linker rather) to export a function from this
ER> DLL? Is it the old __declspec (dllexport) stuff or something similar?
You need minwg32 package rather than the cygwin package. The minwg32
version contains the utils to create Windows DLLs. You need to build a
cross gcc/g++ compiler, plus a cross gas assembler (this might be part
of binutils). You would (eventually) use i386-mingw32-dlltool and
i386-mingw32-dllwrap to create the DLL. Here is a Makefile snippet:
...
DLLWRAP = /usr/local/cross-tools/bin/i386-mingw32-dllwrap
DRIVER = /usr/local/cross-tools/bin/i386-mingw32-gcc
DLLTOOL = /usr/local/cross-tools/bin/i386-mingw32-dlltool
AS = /usr/local/cross-tools/bin/i386-mingw32-as
RANLIB = /usr/local/cross-tools/bin/i386-mingw32-ranlib
...
$(TARGETDLL) : $(OBJS) ../Lib/lib$(TARGET).a $(TARGETDEF)
$(DLLWRAP) --entry _DllMainCRTStartup@12 -dll \
--verbose \
--target i386-mingw32 \
--output-lib $(TARGETLIB) \
--dllname $(TARGETDLL) \
--def $(TARGETDEF) \
--dlltool-name $(DLLTOOL) \
--as $(AS) \
$(OBJS) ../Lib/lib$(TARGET).a \
-Wl,-s \
-Wl,$(TCL_SHARED_LIBS) \
-Wl,-lstdc++ $(conlibsdll)
ER>
ER> Thanx,
ER> Reinhard.
ER>
\/
Robert Heller ||InterNet: heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller || heller@deepsoft.com
http://www.deepsoft.com /\FidoNet: 1:321/153