Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cf3d93a

Browse files
committedDec 30, 2011
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.
1 parent 16569fe commit cf3d93a

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed
 

‎Makefile.in

+8-13
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ TARGET = libSDL.la
3636
SOURCES = @SOURCES@
3737
OBJECTS = @OBJECTS@
3838

39-
SDLMAIN_TARGET = libSDLmain.a
39+
SDLMAIN_TARGET = libSDLmain.la
4040
SDLMAIN_SOURCES = @SDLMAIN_SOURCES@
4141
SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
42+
SDLMAIN_LDFLAGS = @SDLMAIN_LDFLAGS@
4243

4344
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
4445

@@ -65,22 +66,17 @@ $(objects):
6566

6667
.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
6768
depend:
68-
@SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \
69+
@SOURCES="$(SOURCES) $(SDLMAIN_SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \
6970
$(SHELL) $(auxdir)/makedep.sh
70-
@for src in $(SDLMAIN_SOURCES); do \
71-
obj=`echo $$src | sed -e 's|.*/||' -e 's|\.[^\.]*$$|.o|'`; \
72-
echo "\$$(objects)/$$obj: $$src" >>$(depend); \
73-
echo " \$$(CC) \$$(CFLAGS) \$$(EXTRA_CFLAGS) -c $$src -o \$$@" >>$(depend); \
74-
done
7571

7672
include $(depend)
7773

7874
$(objects)/$(TARGET): $(OBJECTS)
79-
$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
75+
$(LIBTOOL) --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
8076

8177
$(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
82-
$(AR) cru $@ $(SDLMAIN_OBJECTS)
83-
$(RANLIB) $@
78+
$(LIBTOOL) --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(SDLMAIN_LDFLAGS)
79+
8480

8581
install: all install-bin install-hdrs install-lib install-data install-man
8682
install-bin:
@@ -95,8 +91,7 @@ install-hdrs:
9591
install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)
9692
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
9793
$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
98-
$(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
99-
$(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
94+
$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
10095
install-data:
10196
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal
10297
$(INSTALL) -m 644 $(srcdir)/sdl.m4 $(DESTDIR)$(datadir)/aclocal/sdl.m4
@@ -120,7 +115,7 @@ uninstall-hdrs:
120115
-rmdir $(DESTDIR)$(includedir)/SDL
121116
uninstall-lib:
122117
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET)
123-
rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
118+
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
124119
uninstall-data:
125120
rm -f $(DESTDIR)$(datadir)/aclocal/sdl.m4
126121
rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl.pc

‎SDL.qpg.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
<QPG:Add filetype="symlink" file="libSDL.so" install="/usr/lib/" linkto="libSDL-@SDL_MAJOR_VERSION@.@SDL_MINOR_VERSION@.so.@LT_AGE@"/>
2929
<QPG:Add permissions="0644" file="./src/.libs/libSDL.a" install="/usr/lib/"/>
3030
<QPG:Add permissions="0644" file="./src/.libs/libSDL.lai" install="/usr/lib/libSDL.la"/>
31-
<QPG:Add permissions="0644" file="./src/main/libSDLmain.a" install="/usr/lib/"/>
31+
<QPG:Add permissions="0644" file="./src/.libs/libSDLmain.a" install="/usr/lib/"/>
32+
<QPG:Add permissions="0644" file="./src/.libs/libSDLmain.lai" install="/usr/lib/libSDLmain.lai"/>
3233
<QPG:Add permissions="0644" file="./include/*.h" install="/usr/include/SDL/"/>
3334
<QPG:Add permissions="0755" file="./sdl-config" install="/usr/bin/"/>
3435
<QPG:Add permissions="0644" file="./BUGS" install="/usr/share/doc/SDL12/"/>

‎build-scripts/makedep.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ search_deps()
4141
for src in $SOURCES
4242
do echo "Generating dependencies for $src"
4343
ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
44-
if test x"$ext" = x"rc"; then
45-
obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"`
46-
else
47-
obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
48-
fi
44+
obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
4945
echo "\$(objects)/$obj: $src \\" >>${output}.new
50-
search_deps $src | sort | uniq >>${output}.new
46+
47+
# No search to be done with Windows resource files
48+
if test x"$ext" != x"rc"; then
49+
search_deps $src | sort | uniq >>${output}.new
50+
fi
5151
case $ext in
5252
c) cat >>${output}.new <<__EOF__
5353
@@ -81,7 +81,7 @@ __EOF__
8181
;;
8282
rc) cat >>${output}.new <<__EOF__
8383
84-
\$(WINDRES) $src \$@
84+
\$(LIBTOOL) --tag=RC --mode=compile \$(WINDRES) $src -o \$@
8585
8686
__EOF__
8787
;;

‎configure.in

+11-5
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,7 @@ AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [[default=no]]]
15561556
AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA)
15571557
SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc"
15581558
SDLMAIN_SOURCES="$srcdir/src/main/qtopia/*.cc"
1559+
SDLMAIN_LDFLAGS="-static"
15591560
EXTRA_CFLAGS="$EXTRA_CFLAGS $QTOPIA_FLAGS"
15601561
SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main"
15611562
SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
@@ -2548,8 +2549,9 @@ case "$host" in
25482549
# The Win32 platform requires special setup
25492550
SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
25502551
SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
2552+
SDLMAIN_LDFLAGS="-static"
25512553
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
2552-
SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
2554+
SDL_LIBS="-lSDLmain $SDL_LIBS -mwindows"
25532555
;;
25542556
*-wince*)
25552557
ARCH=win32
@@ -2591,6 +2593,7 @@ case "$host" in
25912593
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl"
25922594
# The Win32 platform requires special setup
25932595
SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
2596+
SDLMAIN_LDFLAGS="-static"
25942597
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
25952598
SDL_LIBS="-lSDLmain $SDL_LIBS"
25962599
;;
@@ -2722,6 +2725,7 @@ case "$host" in
27222725
fi
27232726
# The Mac OS X platform requires special setup.
27242727
SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
2728+
SDLMAIN_LDFLAGS="-static"
27252729
EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
27262730
SDL_LIBS="-lSDLmain $SDL_LIBS"
27272731
if test x$enable_video_cocoa = xyes; then
@@ -2858,18 +2862,19 @@ if test x$have_loadso != xyes; then
28582862
fi
28592863
if test x$SDLMAIN_SOURCES = x; then
28602864
SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
2865+
SDLMAIN_LDFLAGS="-static"
28612866
fi
28622867

28632868
OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
28642869
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
28652870
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
28662871
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
28672872
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
2868-
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
2873+
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'`
28692874

2870-
SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'`
2871-
SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.o,g'`
2872-
SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
2875+
SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
2876+
SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
2877+
SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
28732878

28742879
# Set runtime shared library paths as needed
28752880

@@ -2931,6 +2936,7 @@ AC_SUBST(SOURCES)
29312936
AC_SUBST(OBJECTS)
29322937
AC_SUBST(SDLMAIN_SOURCES)
29332938
AC_SUBST(SDLMAIN_OBJECTS)
2939+
AC_SUBST(SDLMAIN_LDFLAGS)
29342940
AC_SUBST(BUILD_CFLAGS)
29352941
AC_SUBST(EXTRA_CFLAGS)
29362942
AC_SUBST(BUILD_LDFLAGS)

0 commit comments

Comments
 (0)
Please sign in to comment.