From cf3d93a38107b3590d5e34bd968d19ee5f25314c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 30 Dec 2011 14:14:45 -0500 Subject: [PATCH] Fixed bug 938 - SDL fails to link in mingw+msys+libtool Carlo Bramini 2010-01-27 10:06:17 PST When building third party software powered by libtool (like xine-lib and several others) under Mingw+MSys, libSDL fails to link. I got this message when building SDL video out component of xine-lib: *** Warning: linker path does not have real file for library -lmingw32. *** I have the capability to make that library automatically link in when *** you link to this library. But I can only do this if you have a *** shared version of the library, which you do not appear to have *** because I did check the linker path looking for a file starting *** with libmingw32 and none of the candidates passed a file format test *** using a file magic. Last file checked: /mingw/lib/libmingw32.a Apparently there is no need to manually add -lmingw32 for making libSDL working. If this flag is removed, everything is built without troubles. If it has been added for fixing a cross-compiler, perhaps if would be a better idea to adjust its SPECS file in the same manner it has been done in the true one used by mingw on Windows (I'm just guessing why it exists here). There is also another message received on the console: *** Warning: linker path does not have real file for library -lSDLmain. *** I have the capability to make that library automatically link in when *** you link to this library. But I can only do this if you have a *** shared version of the library, which you do not appear to have *** because I did check the linker path looking for a file starting *** with libSDLmain and none of the candidates passed a file format test *** using a file magic. Last file checked: /mingw/lib/libSDLmain.a This message, like previous one, is caused by -no-undefined flag sent to libtool when building shared libraries. Actually adding an .la file with its dependencies solves the troubles, so I believe it would be better to create it too in the build process of libSDL. --- Makefile.in | 21 ++++++++------------- SDL.qpg.in | 3 ++- build-scripts/makedep.sh | 14 +++++++------- configure.in | 16 +++++++++++----- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Makefile.in b/Makefile.in index c7e52622f..ab51035e0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -36,9 +36,10 @@ TARGET = libSDL.la SOURCES = @SOURCES@ OBJECTS = @OBJECTS@ -SDLMAIN_TARGET = libSDLmain.a +SDLMAIN_TARGET = libSDLmain.la SDLMAIN_SOURCES = @SDLMAIN_SOURCES@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@ +SDLMAIN_LDFLAGS = @SDLMAIN_LDFLAGS@ DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS CWprojects.sea.bin docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in MPWmake.sea.bin README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualCE VisualC.html VisualC Watcom-OS2.zip Watcom-Win32.zip symbian.zip WhatsNew Xcode @@ -65,22 +66,17 @@ $(objects): .PHONY: all depend install install-bin install-hdrs install-lib install-data install-man uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data uninstall-man clean distclean dist depend: - @SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \ + @SOURCES="$(SOURCES) $(SDLMAIN_SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \ $(SHELL) $(auxdir)/makedep.sh - @for src in $(SDLMAIN_SOURCES); do \ - obj=`echo $$src | sed -e 's|.*/||' -e 's|\.[^\.]*$$|.o|'`; \ - echo "\$$(objects)/$$obj: $$src" >>$(depend); \ - echo " \$$(CC) \$$(CFLAGS) \$$(EXTRA_CFLAGS) -c $$src -o \$$@" >>$(depend); \ - done include $(depend) $(objects)/$(TARGET): $(OBJECTS) - $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) + $(LIBTOOL) --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS) - $(AR) cru $@ $(SDLMAIN_OBJECTS) - $(RANLIB) $@ + $(LIBTOOL) --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(SDLMAIN_LDFLAGS) + install: all install-bin install-hdrs install-lib install-data install-man install-bin: @@ -95,8 +91,7 @@ install-hdrs: install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir) $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET) - $(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET) - $(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET) + $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET) install-data: $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal $(INSTALL) -m 644 $(srcdir)/sdl.m4 $(DESTDIR)$(datadir)/aclocal/sdl.m4 @@ -120,7 +115,7 @@ uninstall-hdrs: -rmdir $(DESTDIR)$(includedir)/SDL uninstall-lib: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET) - rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET) + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET) uninstall-data: rm -f $(DESTDIR)$(datadir)/aclocal/sdl.m4 rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl.pc diff --git a/SDL.qpg.in b/SDL.qpg.in index 8e1ff8da8..821faa31e 100644 --- a/SDL.qpg.in +++ b/SDL.qpg.in @@ -28,7 +28,8 @@ - + + diff --git a/build-scripts/makedep.sh b/build-scripts/makedep.sh index e2c57ad38..3b3863b4c 100755 --- a/build-scripts/makedep.sh +++ b/build-scripts/makedep.sh @@ -41,13 +41,13 @@ search_deps() for src in $SOURCES do echo "Generating dependencies for $src" ext=`echo $src | sed 's|.*\.\(.*\)|\1|'` - if test x"$ext" = x"rc"; then - obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"` - else - obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"` - fi + obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"` echo "\$(objects)/$obj: $src \\" >>${output}.new - search_deps $src | sort | uniq >>${output}.new + + # No search to be done with Windows resource files + if test x"$ext" != x"rc"; then + search_deps $src | sort | uniq >>${output}.new + fi case $ext in c) cat >>${output}.new <<__EOF__ @@ -81,7 +81,7 @@ __EOF__ ;; rc) cat >>${output}.new <<__EOF__ - \$(WINDRES) $src \$@ + \$(LIBTOOL) --tag=RC --mode=compile \$(WINDRES) $src -o \$@ __EOF__ ;; diff --git a/configure.in b/configure.in index 18e4c5903..65cd8c331 100644 --- a/configure.in +++ b/configure.in @@ -1556,6 +1556,7 @@ AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [[default=no]]] AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA) SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc" SDLMAIN_SOURCES="$srcdir/src/main/qtopia/*.cc" + SDLMAIN_LDFLAGS="-static" EXTRA_CFLAGS="$EXTRA_CFLAGS $QTOPIA_FLAGS" SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main" SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte" @@ -2548,8 +2549,9 @@ case "$host" in # The Win32 platform requires special setup SOURCES="$SOURCES $srcdir/src/main/win32/*.rc" SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c" + SDLMAIN_LDFLAGS="-static" SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main" - SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows" + SDL_LIBS="-lSDLmain $SDL_LIBS -mwindows" ;; *-wince*) ARCH=win32 @@ -2591,6 +2593,7 @@ case "$host" in EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl" # The Win32 platform requires special setup SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c" + SDLMAIN_LDFLAGS="-static" SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420" SDL_LIBS="-lSDLmain $SDL_LIBS" ;; @@ -2722,6 +2725,7 @@ case "$host" in fi # The Mac OS X platform requires special setup. SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m" + SDLMAIN_LDFLAGS="-static" EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings" SDL_LIBS="-lSDLmain $SDL_LIBS" if test x$enable_video_cocoa = xyes; then @@ -2858,6 +2862,7 @@ if test x$have_loadso != xyes; then fi if test x$SDLMAIN_SOURCES = x; then SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c" + SDLMAIN_LDFLAGS="-static" fi OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'` @@ -2865,11 +2870,11 @@ OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'` OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'` OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'` -OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'` +OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'` -SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'` -SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.o,g'` -SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'` +SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'` +SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'` +SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` # Set runtime shared library paths as needed @@ -2931,6 +2936,7 @@ AC_SUBST(SOURCES) AC_SUBST(OBJECTS) AC_SUBST(SDLMAIN_SOURCES) AC_SUBST(SDLMAIN_OBJECTS) +AC_SUBST(SDLMAIN_LDFLAGS) AC_SUBST(BUILD_CFLAGS) AC_SUBST(EXTRA_CFLAGS) AC_SUBST(BUILD_LDFLAGS)