Skip to content

Commit

Permalink
Fixed bug 938 - SDL fails to link in mingw+msys+libtool
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Dec 30, 2011
1 parent 16569fe commit cf3d93a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
21 changes: 8 additions & 13 deletions Makefile.in
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion SDL.qpg.in
Expand Up @@ -28,7 +28,8 @@
<QPG:Add filetype="symlink" file="libSDL.so" install="/usr/lib/" linkto="libSDL-@SDL_MAJOR_VERSION@.@SDL_MINOR_VERSION@.so.@LT_AGE@"/>
<QPG:Add permissions="0644" file="./src/.libs/libSDL.a" install="/usr/lib/"/>
<QPG:Add permissions="0644" file="./src/.libs/libSDL.lai" install="/usr/lib/libSDL.la"/>
<QPG:Add permissions="0644" file="./src/main/libSDLmain.a" install="/usr/lib/"/>
<QPG:Add permissions="0644" file="./src/.libs/libSDLmain.a" install="/usr/lib/"/>
<QPG:Add permissions="0644" file="./src/.libs/libSDLmain.lai" install="/usr/lib/libSDLmain.lai"/>
<QPG:Add permissions="0644" file="./include/*.h" install="/usr/include/SDL/"/>
<QPG:Add permissions="0755" file="./sdl-config" install="/usr/bin/"/>
<QPG:Add permissions="0644" file="./BUGS" install="/usr/share/doc/SDL12/"/>
Expand Down
14 changes: 7 additions & 7 deletions build-scripts/makedep.sh
Expand Up @@ -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__
Expand Down Expand Up @@ -81,7 +81,7 @@ __EOF__
;;
rc) cat >>${output}.new <<__EOF__
\$(WINDRES) $src \$@
\$(LIBTOOL) --tag=RC --mode=compile \$(WINDRES) $src -o \$@
__EOF__
;;
Expand Down
16 changes: 11 additions & 5 deletions configure.in
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
;;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2858,18 +2862,19 @@ 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'`
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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cf3d93a

Please sign in to comment.