what can link.exe do that cygwin32-ld can't ?

Mikey *jeffdb@netzone.nospam.com
Thu Jul 17 20:04:00 GMT 1997


Not that I can tell no, the only relocatable .dll that I have been
able to make since I switched to B18 is cygwin.dll.

Every other .dll that I have tried to link with cygwin.dll and with a .reloc section gives
unable to run XXX.exe

attached are GNUmakefiles for a project with a dll,
when linked using mingw32 and either 2pass or 3pass the .dll and .exe both work
correctly, when linked with -lcygwin the .exe always gives
an unable to run m:\path\demo.exe dialog box, the only difference
obviously is in the startup files, and the libc services provider.

The same project linked with a nonrelocateble dll will link/run
using either mingw32 or B18.

Also when linked with B17.1 using the 2pass method the dll and exe
both worked.

If anyone can tell me what I'm doing wrong I would appreciate
the comments, otherwise I would speculate that moving _reent_data
into cygwin.dll wasn't as good of an idea as was originally thought.

On Sun, 13 Jul 1997 20:26:49 -0700, you wrote:
>
>   and if so, does this fix makeing .reloc dll's & exe's
>   with B18?
>
>Doesn't that have more to do with running ld and dlltool multiple
>times?
>
>Ian

(*jeffdb@netzone.nospam.com)
Remove *&.nospam from the above to reply
         Mikey
-------------- next part --------------
# =========================================================================
# CYGWIN32.MAK - Win32 application master MAKE definitions file for the
#              Microsoft Win32 SDK for Windows programming samples
#	       and cygwin32/mingw32 gcc
#	       mingw32 headers/startupfiles are in /usr/local/include etc.
#	       cygwin32 headers etc. are in /usr/H-i386-cygwin32
# -------------------------------------------------------------------------
# This files should be included at the top of all MAKEFILEs as follows:
#  replace !include <win32.mak> with include /usr/local/include/cygwin32.mak
#  and change the include and lib paths on line 113 to fit your system
# -------------------------------------------------------------------------
#
# Define APPVER = [ 3.51 | 4.0 ] prior to including win32.mak to get
#  build time checking for version dependencies
#
# Define TARGETOS = [ WIN95 | WINNT | BOTH ] prior to including cygwin32.mak
#  to get some build time checking for platform dependencies.
#
# Define TARGETLANG = [ LANG_JAPANESE ] prior to including cygwin32.mak to get
#  compile & link flags for building applications to run on Japanese Windows.
#  (This is an optional parameter.  The system locale is the default.)
#                  TARGETLANG NOT CURRENTLY IMPLIMENTED
#
# -------------------------------------------------------------------------
# MAKE Options
#
# Use the table below to determine the additional options for MAKE to
# generate various application debugging, profiling and performance tuning
# information.
#
# Application Information Type         Invoke MAKE
# ----------------------------         ------------
# For a debug version                  make
# For No Debugging Info                make NODEBUG=1 mingw32
# For Working Set Tuner Info           make TUNE=1    mingw32 + -O3 (production)
# For Call Attributed Profiling Info   make PROFILE=1  #currently not imp
#
# Note: The three options above are mutually exclusive (you may use only
#       one to compile/link the application).
#
# Note: creating the environment variables NODEBUG, TUNE, and PROFILE is an
#       alternate method to setting these options via the make command line.
#
# Additional MAKE Options              Invoke MAKE
# ----------------------------         ------------
# For No ANSI NULL Compliance          make NO_ANSI=1
# (ANSI NULL is defined as PVOID 0)
# For Extra CFLAGS 		       make CFLAGS="-m386 -O1" for example
#
# =========================================================================

ifneq ($(_WIN32_MAK_),1)
_WIN32_MAK_ = 1

# -------------------------------------------------------------------------
# Get CPU Type - default to i386 if not set
# -------------------------------------------------------------------------

ifeq ($(CPU),)
CPU = i386
endif

ifneq ($(CPU),i386)
ifneq ($(CPU),MIPS)
ifneq ($(CPU),ALPHA)
ifneq ($(CPU),PPC)
ifneq ($(CPU),RANDOM)
	echo Error Nust specify CPU env var ( i386 MIPS ALPHA PPC )
ERROR
endif
endif
endif
endif
endif

# -------------------------------------------------------------------------
# Get Target Operating System - Default to BOTH
# -------------------------------------------------------------------------

ifeq ($(TARGETOS),)
TARGETOS = BOTH
endif

ifneq ($(TARGETOS),BOTH)
ifneq ($(TARGETOS),WINNT)
ifneq ($(TARGETOS),WIN95)
ifneq ($(TARGETOS),RANDOM)
	echo Must specify TARGETOS environment variable (BOTH, WIN95, WINNT)
ERROR
endif
endif
endif
endif


ifeq ($(APPVER),)
APPVER = 4.0
endif

ifneq ($(APPVER),4.0)
ifneq ($(APPVER),3.51)
	echo Must specify APPVER environment variable (3.51, 4.0)
ERROR
endif
endif

############          Change These to fit Your Setup  #########################

#for rc.exe use with rsrc.exe
CYGVER=`gcc -v 2>&1|grep -v Reading|sed s/gcc\\ version\\ //`
COMPINCRCPATH	= `gcc -print-file-name=crt0.o|sed -e s/\\\\\\\\/\\\\//g -e s/lib\\\\/crt0.o//`include
MINGW32RCPATH	= $(COMPINCRCPATH)/ming
WIN32RCPATH	= $(COMPINCRCPATH)/win32
SYSINCRCPATH	= $(COMPINCRCPATH)/../../lib/gcc-lib/i386-cygwin32/$(CYGVER)/include


# binary declarations common to all platforms

ifneq ($(NODEBUG),)  #for production use mingw32
cc     = gcc -wm
rc	= rc /i$(WIN32RCPATH) /i$(MINGW32RCPATH)
else	#to debug use cygwin32
cc     = gcc
rc	= rc /i$(WIN32RCPATH) /i$(COMPINCRCPATH) /i$(SYSINCRCPATH)
endif	# NODEBUG

link   = $(cc)
implib = dlltool
hc     = hcrtf -xn

# for compatibility with older-style makefiles
cvtobj = REM !!! CVTOBJ is no longer necessary - please remove !!!
cvtres = REM !!! CVTRES is no longer necessary - please remove !!!


# -------------------------------------------------------------------------
# Platform Dependent Compile Flags - must be specified after $(cc)
#
# Note: Debug switches are on by default for current release
#
# These switches allow for source level debugging with WinDebug for local
# and global variables.
#
# Both compilers now use the same front end - you must still define either
# _X86_, _MIPS_, _PPC_ or _ALPHA_.  These have replaced the i386, MIPS, and ALPHA
# definitions which are not ANSI compliant.
#
# Common compiler flags:
#   gcc	  cl
#   -c	  -c	- compile without linking
#   -Wall -W3  - Set warning level to level 3
#   -g	  -Zi  - generate debugging information
#   -O0	  -Od  - disable all optimizations
#   -O3	  -Ox  - use maximum optimizations
#   N/A	  -Zd  - generate only public symbols and line numbers for debugging
#
# i386 specific compiler flags:
#   N/A	  -Gz  - stdcall
#
# -------------------------------------------------------------------------

# declarations common to all compiler options
ccommon = -c -windows -Wall -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl

ifeq ($(TARGETLANG),LANG_JAPANESE)
ccommon += -DJAPAN -DDBCS -DFE_IME
endif

ifeq ($(TARGETLANG),LANG_CHINESE)
ccommon += -DDBCS -DFE_IME
endif

ifeq ($(TARGETLANG),LANG_KOREAN)
ccommon += -DDBCS -DFE_IME
endif



ifeq ($(CPU),i386)
cflags = $(ccommon)
scall  =
else
ifeq ($(CPU),MIPS)
cflags = $(ccommon) -D_MIPS_=1 -D_M_MRX000 
else
ifeq ($(CPU),PPC)
cflags = $(ccommon) -D_PPC_=1 -D_M_MPPC 
else
ifeq ($(CPU),ALPHA)
cflags = $(ccommon) -D_ALPHA_=1 -D_M_ALPHA
endif
endif
endif
scall  =
endif

ifeq ($(TARGETOS),WINNT)
cflags += -D_WINNT -D_WIN32_WINNT=0x0400
else
ifeq ($(TARGETOS),WIN95)
cflags += -D_WIN95 -D_WIN32_WINDOWS=0x0400
endif
endif

ifneq ($(NODEBUG),) 
cdebug = -O 
else
ifneq ($(PROFILE),) #NOT Imp
cdebug = -p
else
ifneq ($(TUNE),)
cdebug = -O3 
else 
cdebug = -g -O 
endif
endif
endif

# -------------------------------------------------------------------------
# Target Module & Subsystem Dependent Compile Defined Variables - must be
#   specified after $(cc)
#
# The following table indicates the various acceptable combinations of
# the C Run-Time libraries LIBCYGWIN, and CRTDLL with respect to the creation
# of a EXE and/or DLL target object.  The appropriate compiler flag macros
# that should be used for each combination are also listed.
#
#  Link EXE    Create Exe    Link DLL    Create DLL
#    with        Using         with         Using
# ----------------------------------------------------
#  LIBCYGWIN   CVARS          None        None      *
#  LIBCYGWIN   CVARS          LIBCYGWIN   CVARS
#  CRTDLL      CVARSDLL       None        None      *
#  CRTDLL      CVARSDLL       LIBC        CVARS
#  CRTDLL      CVARSDLL       CRTDLL      CVARSDLL  *
#
# * - Denotes the Recommended Configuration
#
# When building single-threaded applications you can link your executable
# with either LIBCYGWIN, or CRTDLL, although CRTDLL will provide the best
# performance.
#
# When building multi-threaded applications, CRTDLL can
# be used as the C-Runtime library, multi-thread safe.
#
# Note: Any executable which accesses a DLL linked with libcrtdll.a must
#       also link with libcrtdll.a instead of libcygwin.a
#       When using DLLs, it is recommended that all of the modules be
#       linked with libcrtdll.a.
#
# Note: The macros of the form xDLL are used when linking the object with
#       the DLL version of the C Run-Time (that is, libcrtdll.a).  They are
#       not used when the target object is itself a DLL.
#
# -------------------------------------------------------------------------

ifneq ($(NO_ANSI),)
noansi = -DNULL=0
endif

# for Windows applications that use the C Run-Time libraries
cvars      = $(noansi)
cvarsmt    = $(cvars) 
cvarsdll   = $(cvars) -D_DLL

# for compatibility with older-style makefiles
cvarsmtdll   = $(cvarsmt) -D_DLL

# for POSIX applications
psxvars    = -D_POSIX_ #NT posix subsystem

# resource compiler
rcflags = /dRC_INVOKED# for rc lrc
rcvars = /dWIN32 /d_WIN32 /dWINVER=0x0400 #for rc lrc

ifeq ($(TARGETLANG),LANG_JAPANESE)
rcflags += /c932
rcvars += -DJAPAN -DDBCS -DFE_IME
endif

ifeq ($(TARGETLANG),LANG_CHINESE)
rcvars += -DDBCS -DFE_IME
endif

ifeq ($(TARGETLANG),LANG_KOREAN)
rcvars += -DDBCS -DFE_IME
endif

# -------------------------------------------------------------------------
# Platform Dependent Link Flags - must be specified after $(link)
#
# Note: $(DLLENTRY) should be appended to each -e flag on the link
#       line.
#
# Note: When creating a DLL that uses C Run-Time functions it is
#       recommended to include the entry point function of the name DllMain
#       in the DLL's source code.  Also, the MAKEFILE should include the
#       -e _DllMainCRTStartup$(DLLENTRY) option for the creation of
#       this DLL.  (The C Run-Time entry point _DllMainCRTStartup in turn
#       calls the DLL defined DllMain entry point.)
#
# -------------------------------------------------------------------------

# declarations common to all linker options
lflags  = 

# declarations for use on Intel i386, i486, and Pentium systems
ifeq ($(CPU),i386)
DLLENTRY = @12
endif

# declarations for use on self hosted MIPS R4x000 systems
ifeq ($(CPU),MIPS)
DLLENTRY =
endif

# declarations for use on self hosted PowerPC systems
ifeq ($(CPU),PPC)
DLLENTRY =
endif

# declarations for use on self hosted Digital Alpha AXP systems
ifeq ($(CPU),ALPHA)
DLLENTRY =
endif

# -------------------------------------------------------------------------
# Target Module Dependent Link Debug Flags - must be specified after $(link)
#
# These switches allow the inclusion of the necessary symbolic information
# for source level debugging with WinDebug, profiling and/or performance
# tuning.
#
# Note: Debug switches are on by default.
# -------------------------------------------------------------------------

ifneq ($(NODEBUG),)
ldebug = 
else
ifneq ($(PROFILE),)
ldebug = 
else
ifneq ($(TUNE),)
ldebug = 
else
ldebug = 
endif
endif
endif

# for compatibility with older-style makefiles
linkdebug = $(ldebug)

# -------------------------------------------------------------------------
# Subsystem Dependent Link Flags - must be specified after $(link)
#
# These switches allow for source level debugging with WinDebug for local
# and global variables.  They also provide the standard application type and
# entry point declarations.
#
# Note that on x86 screensavers have a WinMain entrypoint, but on RISC
# platforms it is main.  This is a Win95 compatibility issue.
#
# -------------------------------------------------------------------------

# for Windows applications that use the C Run-Time libraries

conlflags = $(lflags) -console 

ifeq ($(NODEBUG),)
guilflags = $(lflags) -windows
else
guilflags = $(lflags) -windows
endif

dlllflags = $(lflags) -dll 

ifeq ($(CPU),i386)
ifeq ($(NODEBUG),)
savlflags = $(lflags) -windows -Wl,-e,WinMainCRTStartup@16
else
savlflags = $(lflags) -windows -Wl,-e,WinMainCRTStartup@16
endif
else
savlflags = $(lflags) -windows -Wl,-e,mainCRTStartup
endif

# for POSIX applications
psxlflags = $(lflags)

# for compatibility with older-style makefiles
conflags  = $(conlflags)
guiflags  = $(guilflags)
psxflags  = $(psxlflags)

# -------------------------------------------------------------------------
# C Run-Time Target Module Dependent Link Libraries
#
# Below is a table which describes which libraries to use depending on the
# target module type, although the table specifically refers to Graphical
# User Interface apps, the exact same dependencies apply to Console apps.
# That is, you could replace all occurrences of 'GUI' with 'CON' in the
# following:
#
# Desired CRT  Libraries   Desired CRT  Libraries
#   Library     to link      Library     to link
#   for EXE     with EXE     for DLL     with DLL
# ----------------------------------------------------
#   LIBCYGWIN  GUILIBS       None       None       *
#   LIBCYGWIN  GUILIBS       LIBCYGWIN  GUILIBS
#   CRTDLL     GUILIBSDLL    None       None       *
#   CRTDLL     GUILIBSDLL    LIBCYGWIN  GUILIBS
#   CRTDLL     GUILIBSDLL    CRTDLL     GUILIBSDLL *
#
# * - Recommended Configurations.
#
# Note: Any executable which accesses a DLL linked with libcrtdll.a must
#       also link with libcrtdll.a instead of libcygwin.a 
#
# Note: For POSIX applications, link with libcygwin.a.
#
# -------------------------------------------------------------------------

# These CRT Libraries assume the use of gnu C/C++.  If you are
# using another Compiler product, change the libc* variable to correspond
# to your import library names.

libc = -loldnames 

libcmt = $(libc)

libcdll = -loldnames

# for POSIX applications
psxlibs    = -loldnames


# optional profiling and tuning libraries
ifneq ($(PROFILE),)
optlibs =  -lcap
else
ifneq ($(TUNE),)
optlibs = # -lwst
else
optlibs =
endif
endif

# if building for Windows NT 4 or greater, switch over to WinSock2
ifeq ($(TARGETOS),WINNT)
ifneq ($(APPVER),3.51)
winsocklibs = -lws2_32 -lmswsock
else
winsocklibs = -lwsock32
endif
else
winsocklibs = -lwsock32
endif

# basic subsystem specific libraries, less the C Run-Time
baselibs   = $(optlibs) $(winsocklibs) -ladvapi32
winlibs    = $(baselibs) -lwinspool

# for Windows applications that use the C Run-Time libraries
conlibs    = $(libc) $(baselibs)
conlibsmt  = $(libcmt) $(baselibs)
conlibsdll = $(libcdll) $(baselibs)
guilibs    = $(libc) $(winlibs)
guilibsmt  = $(libcmt) $(winlibs)

guilibsdll = $(guilflags) $(libcdll) $(winlibs)

# for OLE applications
olelibs      = -lole32 -luuid -loleaut32 $(guilibs)
olelibsmt    = -lole32 -luuid -loleaut32 $(guilibsmt)
olelibsdll   = -lole32 -luuid -loleaut32 $(guilibsdll)

# for backward compatibility
ole2libs    = $(olelibs)
ole2libsmt  = $(olelibsmt)
ole2libsdll = $(olelibsdll)

.PHONY: all clean distclean linkclean unix
all: # make this the first target or people get confused .)

clean:
	rm -f *.[oO] *.res *.gid *.err *.exp *.RES *.GID *.ERR *.EXP\
        *.base *.BASE *.log *.LOG

distclean: clean
	rm -f *.exe *.dll *.hlp *.[aA] *.EXE *.DLL *.HLP *.ph *.PH

linkclean:
	rm -f *.exe *.dll *.hlp *.[aA] *.EXE *.DLL *.HLP *.base *.exp *.RES *.res

unix:
	-dtou *.[ch] *.cpp GNUmakefile makefile *.rc *.def *.reg *.gak readme.txt *.dlg 

.SUFFIXES: .rc .res .rce .exp .exe .dll .hlp .exp .base .cpp

# make the .exe/.dll a dependency of the .res and put .res in all instead
%.res: %.rc #.exe or .dll
	$(rc) $(rcvars) -r -fo $@ $<
	rsrc $@ $*.exe

# only .o files as dependencies, set DLIBS in Makefile reset for each.
# 
%.base: %.o #$(DOBJS)
	$(link) $(linkdebug) $(dlllflags) \
	$^ -Wl,--base-file,$@ $(guilibsdll) $(DLIBS)

%.exp: %.base
        dlltool --as=as --dllname $*.dll --output-lib lib$*.a --def $< \
		--machine $(CPU) --output-exp $*.exp --base-file $*.base
%.dll: %.exp
	$(link) $(linkdebug) $(dlllflags) -o$@ $^ $(DOBJS) $(guilibsdll)

%.exe: %.o
	$(link) $(linkdebug) $(guiflags) -o$@ $(EOBJS) $(ELIBS) $(guilibsdll)\
	$(DLIBS)



endif # _WIN32_MAK_

-------------- next part --------------
A non-text attachment was scrubbed...
Name: GNUmakefile
Type: text/x-makefile
Size: 1448 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/19970717/b32a06ea/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GNUmakefile.2pass
Type: text/x-makefile
Size: 1399 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/19970717/b32a06ea/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GNUmakefile.3pass
Type: text/x-makefile
Size: 1889 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/19970717/b32a06ea/attachment-0002.bin>


More information about the Cygwin mailing list