Skip to contentSkip to conversation

Fix OS X SDL breakage

PATCH Bernhard Ehlers 2 participants 3 messages Jan 30, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines · Fabrice Bellard

Can you confirm that QEMU for OS X works with this include ? IMHO it was added to add the '#define main SDL_main' define.

Fabrice.

Hi,

Here my test results on my Mac OS X 10.3.7.

I use the qemu-snapshot-2004-12-28_23.tar.bz2 from http://people.fruitsalad.org/nox/ , but the results should be the same on CVS.

1) self compiled SDL V1.2.8

# sdl-config --version --cflags --libs
1.2.8
-I/usr/local/include/SDL -D_THREAD_SAFE
-L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL

a) no change to vl.c
compiles OK, links OK, runs OK

b) remove the #include SDL/SDL.h in vl.c
compiles OK, links OK, crashes during execution

2005-01-29 11:31:55.502 qemu[1222] *** _NSAutoreleaseNoPool(): Object 0x1b01550 of class NSCFArray autoreleased with no pool in place - just leaking
.
.
.
2005-01-29 11:31:55.533 qemu[1222] *** _NSAutoreleaseNoPool(): Object 0x1b39850 of class NSException autoreleased with no pool in place - just leaking
2005-01-29 11:31:55.533 qemu[1222] *** Uncaught exception: <NSInternalInconsistencyException> Error (1002) creating CGSWindow

2) Fink sdl v1.2.7-1

# sdl-config --version --cflags --libs
1.2.7
-I/sw/include/SDL -D_THREAD_SAFE
-L/sw/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL

a) no change to vl.c
compile error in vl.c, include file SDL/SDL.h not found

b) remove the #include SDL/SDL.h in vl.c compiles OK, links OK, crashes during execution (see 1b)

So the removal of the #include <SDL/SDL.h> crashes the executable on MAC OSX. That means it has to stay.

On the other side it compiles only for the default SDL installation because /usr/local/include is in the default include search path. The problem is, that for the compilation of vl.c the SDL include path (sdl-config --cflags) is not used.

My proposal is to modify the Makefiles, so that for the compilation of vl.c the SDL_CFLAGS are used.

Here my patches. Now it compiles, links and runs with both SDL libraries.

Best regards

Bernhard Ehlers

Makefile.target +3 -0
diff -ru qemu.orig/Makefile.target qemu/Makefile.target
@@ -348,6 +348,9 @@
 sdlaudio.o: sdlaudio.c
 	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
 
+vl.o: vl.c vl.h
+	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
+
 depend: $(SRCS)
 	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
 
vl.c +1 -1
diff -ru qemu.orig/vl.c qemu/vl.c
@@ -68,7 +68,7 @@
 
 #ifdef CONFIG_SDL
 #ifdef __APPLE__
-#include <SDL/SDL.h>
+#include <SDL.h>
 #endif
 #endif /* CONFIG_SDL */
 
#1 lore raw

[Qemu-devel] SDL fix (was: [PATCH] Fix OS X SDL breakage)

Quoted 1 line · Bernhard Ehlers

So the removal of the #include <SDL/SDL.h> crashes the executable on MAC OSX. That means it has to stay.

Thanks a lot for your investigation. I would call the result surprising but now we should be able to fix this appropriately.

On a side note: I've been looking into the SDL headers and the only thing which seems to affect OS X is the hunk starting in SDL_main.h starting with:

/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */

#if defined(WIN32) || defined(_WIN32) || \
    (defined(__MWERKS__) && !defined(__BEOS__)) || \
    defined(macintosh) || defined(__APPLE__) || \
    defined(__SYMBIAN32__) || defined(QWS)

#ifdef __cplusplus
#define C_LINKAGE "C"
#else
#define C_LINKAGE
#endif /* __cplusplus */

Looking at this it really seems that ...

Review

Quoted 6 lines
(quoted diff) +1 -5
-#ifdef CONFIG_SDL
-#ifdef __APPLE__
-#include <SDL/SDL.h>
+#include <SDL.h>
-#endif
-#endif /* CONFIG_SDL */

might be more sensible and seems nicer to me. Any idea why the Win version seems to work wihtout it?

Servus,
Daniel

#2 lore raw

Re: [Qemu-devel] SDL fix (was: [PATCH] Fix OS X SDL breakage)

Quoted 6 lines · Daniel Egger

Review

Quoted 6 lines
(quoted diff) +1 -5
-#ifdef CONFIG_SDL
-#ifdef __APPLE__
-#include <SDL/SDL.h>
+#include <SDL.h>
-#endif
-#endif /* CONFIG_SDL */

On a side note: I've just verified that this version also works on Linux...

Servus,
Daniel