SDL native on win32 (minor fixes)

I have attached a patch that allows 0.11.3 (cvs) to configure and build
correctly in the test directory for mingw32:

Fixes to src/main/win32/SDL_main.c:

  • added a #if check to _MSVER for mingw32, because mingw32 also requires a
    main() function (or else you’ll get an ‘Undefined Reference to
    WinMain at 16’)
  • I don’t know which one is wrong, but SDL_event (I think) defines
    _SDL_RegisterApp() (which is also in the exports) but SDL_main.c
    declares SDL_RegisterApp(). Added an underscore to all relevant calls.

Fixes to test/configure:

  • The check for the SDL version would break because main was declared as
    main() and not main(int argc, char *argv[]). Fixed this in two spots.

Hack to

  • I hardcoded mingw32-specific libraries to the --libs parameter. Because
    of my unfamiliarity with autoconf’ing, I know of no other way to fix
    this (adding ‘-lSDL -lgdi32 -lwinmm’ to SDL_LIBS in doesn’t
    work because -lSDL is stripped somewhere)
  • This hack exists only to allow 0.11.3 to build under mingw32. From
    reading previous e-mails, it looks like Sam is going to address this in
    one form or another (that is, needing -lgdi32 -lwinmm for sdl-config).

Again, the process that I use to build SDL under mingw32 (assuming you
have i386-mingw32-gcc.exe in your PATH):

Top-level build:
CC=i386-mingw32-gcc configure --target=i386-mingw32 --prefix=/usr/local
–disable-directx -v

I use ‘–disable-directx’ because I’m dev’ing under NT. After configure,
I use:

CC=i386-mingw32-gcc make all install

Test programs:
CC=i386-mingw32-gcc configure --target=i386-mingw32 -v



As far as SDL-demos, I had to copy the patched test/configure over founts
in order for founts to compile. The only other SDL-based program I’ve
tried (other than test/) was LK which worked.

A few concerns:

  • I assume the dll process for mingw32 is broken for now? I’ve tried
    ’–disable-static’ || ‘–enable-shared’ to no avail.

  • I added CheckNASM to mingw32 in only to find that nasm
    freaks out when called from the ‘strip -fPIC’ script. If I manually
    invoke it from the command line, it works fine.

As I become more familiar with the autoconf system, maybe I can help
address these issues.

Oh yeah, updated VisualC stuff is forthcoming.

-------------- next part --------------
diff -urN SDL-0.11.3.orig/ SDL-0.11.3/
— SDL-0.11.3.orig/ Thu Oct 28 19:05:52 1999
+++ SDL-0.11.3/ Sun Oct 31 19:28:27 1999
@@ -46,7 +46,7 @@
libdirs=-L at libdir@

  •  echo $libdirs -lSDL @SDL_LIBS@
  •  echo $libdirs -lSDL @SDL_LIBS@ -lSDL -lgdi32 -lwinmm
    echo “${usage}” 1>&2
    diff -urN SDL-0.11.3.orig/src/main/win32/SDL_main.c SDL-0.11.3/src/main/win32/SDL_main.c
    — SDL-0.11.3.orig/src/main/win32/SDL_main.c Thu Oct 28 19:20:38 1999
    +++ SDL-0.11.3/src/main/win32/SDL_main.c Mon Nov 01 09:13:57 1999
    @@ -26,7 +26,7 @@
    #define STDERR_FILE “stderr.txt”

/* From the SDL library code */
-extern int SDL_RegisterApp(char *name, UINT style, HINSTANCE hInst);
+extern int _SDL_RegisterApp(char *name, UINT style, HINSTANCE hInst);

/* Parse a command line buffer into arguments */
@@ -97,7 +97,9 @@
return FALSE;

-#ifdef _MSC_VER /* The VC++ compiler needs main defined /
The VC++ compiler needs main defined /
mingw32 requires main as well as cygwin */
+#if defined(_MSC_VER) || defined(MINGW32)
#define console_main main

@@ -137,7 +139,7 @@

/* Create and register our class, then run main code */
  • if ( SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT,
  • if ( _SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT,
    GetModuleHandle(NULL)) < 0 ) {
    ShowError(“WinMain() error”, SDL_GetError());
    diff -urN SDL-0.11.3.orig/test/configure SDL-0.11.3/test/configure
    — SDL-0.11.3.orig/test/configure Thu Oct 28 19:34:04 1999
    +++ SDL-0.11.3/test/configure Sun Oct 31 20:00:35 1999
    @@ -1209,7 +1209,7 @@
    return new_str;

-int main ()
+int main (int argc, char *argv[])
int major, minor, micro;
char *tmp_version;
@@ -1283,7 +1283,7 @@
#include <stdio.h>
#include <SDL/SDL.h>

-int main() {
+int main(int argc, char *argv[]) {
return 0;
; return 0; }