Mail Archives: cygwin/1999/11/17/18:58:55
Here is a Makefile that I got from one of Mummit Khan's help files:
#
# Makefile for Cygwin in -mno-cygwin mode. This builds a DLL that is
# independent of Cygwin DLL and only depends on MS CRTDLL runtime.
#
# If you want to use Mingw32 gcc, then use the makeit.bat file instead.
#
CC = gcc
# The root directory for mingw-extra package. You can get this package
# from the same place where you downloaded egcs-1.1.2-cygb20 from.
# You should also read the -mno-cygwin howto available from:
# http://www.xraylith.wisc.edu/~khan/software/gnu-win32/
#
MINGW_EXTRA_ROOT = /usr/local/mingw-extra
MINGW_INCLUDES = -I$(MINGW_EXTRA_ROOT)/include
MINGW_LIBDIRS = -I$(MINGW_EXTRA_ROOT)/lib
DEBUG = -g -O2
# The -mrtd flag tells the compiler to use the PASCAL or "stdcall" calling
# convention required by VBA/Excel/etc.
CFLAGS = -mrtd $(DEBUG)
CPPFLAGS = $(MINGW_INCLUDES)
AS = as
DLLTOOL = dlltool
DLLWRAP = dllwrap
#
# Various targets to build.
#
DLL_NAME = test.dll
DLL_EXP_DEF = test.def
all: $(DLL_NAME)
#
# sources, objects, etc.
#
SRCS = $(wildcard *.c)
OBJS := $(OBJS:.c=.o)
#
# DLL related variables. These are used when building the DLL. See later.
#
# any special flags that you need to pass to the F77 compiler when building
# the DLL. (lots of software need _DLL defined).
DLL_CFLAGS = -DBUILDING_DLL=1
# This is where you pass linker flags, such as library search path, alternate
# entry point, etc. The -s flag strips the final DLL.
DLL_LDFLAGS = $(MINGW_LIBDIRS) -s -W1,-e,_cygwin_nocygwin_init AT 12
# any extra libraries that your DLL may depend on.
DLL_LDLIBS =
#
# your sources etc that go into the DLL.
#
DLL_SRCS = test.c
DLL_OBJS = test.o
###
#
# Making DLL
#
###
#
# Note that we let dllwrap create both the DEF and IMPORT library in
# one shot. No need to run dlltool anymore.
#
DLLWRAP_FLAGS = --export-all --output-def $(DLL_EXP_DEF) \
--target=i386-mingw32 -mno-cygwin \
--driver-name $(CC)
$(DLL_NAME) $(DLL_EXP_DEF): $(DLL_OBJS)
$(DLLWRAP) $(DLLWRAP_FLAGS) -o $(DLL_NAME) \
$(DLL_OBJS) $(DLL_LDFLAGS) $(DLL_LDLIBS)
#
# dependencies.
#
#fdll.o: fdll.c
test.o: test.c
#
# default rules for building DLL objects. Note that client programs (ie.,
# the ones that *use* the DLL) have to be compiled without the DLL_CFLAGS
# flags.
#
.c.o:
$(CC) -c $(CPPFLAGS) $(DLL_CFLAGS) $(CFLAGS) -o $@ $<
clean:
-rm -f $(OBJS) $(DLL_OBJS) $(DLL_NAME) $(DLL_EXP_DEF)
This should allow you to build a dll that is not dependent on cygwin1.dll.
Eric
Torben Mikael Hansen wrote:
> How do I build a DLL that does not use cygwin1.dll
>
> I've tried the following but the DLL still has cygwin1.dll in its import
> table
>
> gcc -c axdrv.cpp -Wall -mno-cygwin
> ld --base-file axdrv.base --dll -o axdrv.dll -e _dll_entry AT 12 axdrv.o
> dlltool --as=as --dllname axdrv.dll --def axdrv.def --base-file axdrv.base
> --output-exp axdrv.exp
> ld --base-file axdrv.base axdrv.exp --dll -o axdrv.dll -e _dll_entry AT 12
> axdrv.o
> dlltool --as=as --dllname axdrv.dll --def axdrv.def --base-file axdrv.base
> --output-exp axdrv.exp
> ld axdrv.exp --dll -o axdrv.dll -e _dll_entry AT 12 axdrv.o
>
> Putting a -mno-cygwin anywhere else results in compile time errors.
>
> Torben
>
> ___________________________________________________
> Torben Mikael Hansen
> Research Assistant
> Nanotechnology
> Mikroelektronik Centret
> DTU Building 345e, DK-2800 Kgs. Lyngby, Denmark
>
> office: 157
> tel.: +45 4525 5731
> lab: +45 4525 5812
> fax: +45 4588 7762
> email: tmh AT mic DOT dtu DOT dk
>
> ------------------------------------------------------------------------
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -