SDL on Win32

Hello folks!

I just subscribed to this mailing list because I would
like to use SDL in Win32 and I’m having trouble
getting it to work.

I downloaded an installed the Native Win32 EGCS
compiler Mingw32 and it seems to work.

Then I got GNUmake on Win32 and that seems
to work too. (I have renamed the make command
to gmake if that is relevant…)

I also downloaded SDL-0.9.9 binary for Win32
(It’s called Win32 (GCC) on your download page,
filename: SDL-0_9_9-win32.tar.gz)
I don’t know if this is the right file. I would like my
application to run using native Windows (i.e. not
DirectX or similar).

I noticed that all libraries are called .a and I’m not
sure if this will work on Win
.

I can’t get any of the demos to work. When compiling
the water-demo I get this error:

cc -I…/…/SDL-0.9.9/include -c water.c -o water.o
process_begin: CreateProcess((null), cc
-I…/…/SDL-0.9.9/include -c water.c -o water.o, …) failed.
make (e=2): The system cannot find the file specified.
gmake: *** [water.o] Error 2

I think it looks strange that there’s a cc command as an argument
to a CreateProcess function…

I also tried to hack up a small makefile which looks like this:

SDL := …/…/…/SDL-0.9.9
MING := …/…/…/Mingw32
SDLINCLUDE := -I$(SDL)/include
SDLLIB := -L$(SDL)/lib
MINGLIB := -L$(MING)/i386-mingw32/lib
SDLLIB := $(SDLLIB) $(MINGLIB) -lmingw32 -lSDL
OPTIMIZE = -O2 -funroll-loops -fomit-frame-pointer -ffast-math

test:
gcc -o test test.cpp $(SDLLIB) $(SDLINCLUDE) $(OPTIMIZE)

And the file test.cpp just looks like this:

#include <stdio.h>
#include <SDL.h>

int main()
{
puts(“Hello World!”);
exit(1);
}

When executing gmake I get this error:

gcc -o test test.cpp -L…/…/…/SDL-0.9.9/lib
-L…/…/…/Mingw32/i386-mingw32/lib
-lmingw32 -lSDL -I…/…/…/SDL-0.9.9/include -O2 -funroll-loops
-fomit-frame-pointer -ffast-math
libSDL.a(winmain.o) : error LNK2001: unresolved external symbol
___imp__iob
libSDL.a(load.o) : error LNK2001: unresolved external symbol ___imp__iob

libSDL.a(winmain.o) : error LNK2001: unresolved external symbol
_RunMain__FiPPc
test.exe : fatal error LNK1120: 2 unresolved externals
gcc: Internal compiler error: program ld got fatal signal 127
gmake: *** [test] Error 1

Can you tell me which trivial thing I forgot to do? :)—
Why I choose SDL and some practical stuff…

I am most likely going to do a very small commercial
game project. I would like to use SDL because:

  1. The game must run on Win32 and I don’t like to
    be limited to one OS (certainly not an MS one) - I prefer
    portable applications…
  2. I would like to avoid buying commercial development tools.
  3. I would like to use something I am familiar with already
    because of a tight deadline. (here I mean the GCC/EGCS
    compiler)

However I would like to see SDL work and run before I
commit to using it.

On a more practical note - if I’m going to release this game
commercially it must fit on a single floppy disk - including
graphics etc. So I don’t think there’s room for the
SDL source-code on the disk. Since it’s under LGPL
and LGPL says that the source-code should be as
easily accessible as the binary files, I would like to
know if you think it’s acceptable if I put a textfile
on the floppy disk telling that the game has been developed
using SDL and including a link to your web-page.

Thanks in advance for any help!

Cheers

?NOQ of the Sun / Johnny Andersen
Hardcore Processing

val it = ("?NOQ of the Sun", “Johnny Andersen”,
[“anoq at vip.cybercity.dk”, “anoq at berlin-consortium.org”,
“anoq at diku.dk”], “http://users.cybercity.dk/~ccc25861/”)
: cyberspacename * meatspacename * email list * homepage URL

I just subscribed to this mailing list because I would
like to use SDL in Win32 and I’m having trouble
getting it to work.

I haven’t worked on a native build of SDL on Win32 in a long time.
I plan to build a new version of the egcs tools relatively soon,
and when I do, I will make sure everything works again.

test:
gcc -o test test.cpp $(SDLLIB) $(SDLINCLUDE) $(OPTIMIZE)

gcc -o test test.cpp -L…/…/…/SDL-0.9.9/lib
-L…/…/…/Mingw32/i386-mingw32/lib
-lmingw32 -lSDL -I…/…/…/SDL-0.9.9/include -O2 -funroll-loops
-fomit-frame-pointer -ffast-math
libSDL.a(winmain.o) : error LNK2001: unresolved external symbol
___imp__iob
libSDL.a(load.o) : error LNK2001: unresolved external symbol ___imp__iob

libSDL.a(winmain.o) : error LNK2001: unresolved external symbol
_RunMain__FiPPc

It sounds like the name mangling isn’t working right, and the library
needs to be recompiled with your compiler. For now, just develop on
Linux, and then when I get the new Win32 native compiler working,
getting it to work on Win32 should just be a matter of recompiling.

I am most likely going to do a very small commercial
game project. I would like to use SDL because:

[snipped]
Hey, can I quote this? :slight_smile:

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Sam Lantinga wrote:

I haven’t worked on a native build of SDL on Win32 in a long time.
I plan to build a new version of the egcs tools relatively soon,
and when I do, I will make sure everything works again.

Sounds nice! I’ll try out one of the older versions of SDL now…

It sounds like the name mangling isn’t working right, and the library
needs to be recompiled with your compiler. For now, just develop on
Linux,

Do you mean cross-compiling to Win* from Linux? I really need to
see apps. work on Win* before committing to SDL, becuase the
game must run on Win*. I’m in the phase now where I have to
tell my customer yes or no if I can do the project (ASAP :),
and if I say yes, I will get in trouble if I can’t do it…

and then when I get the new Win32 native compiler working,
getting it to work on Win32 should just be a matter of recompiling.

I believe that :slight_smile: It’s just that it’s a tight deadline so time
is critical…

I am most likely going to do a very small commercial
game project. I would like to use SDL because:

[snipped]
Hey, can I quote this? :slight_smile:

Sure! Anytime anywhere :slight_smile: FYI, I’m trying to buy a commercial
homepage these days (no commercial stuff allowed on the one I have now),
so if you want a link to my company homepage I’ll post it here when
I get it… (but maybe I will anyway, since I’ll get a new (additional)
e-mail adress too…)

Cheers–
val it = ("?NOQ of the Sun", “Johnny Andersen”,
[“anoq at vip.cybercity.dk”, “anoq at berlin-consortium.org”,
“anoq at diku.dk”], “http://users.cybercity.dk/~ccc25861/”)
: cyberspacename * meatspacename * email list * homepage URL

ANOQ of the Sun wrote:

Sure! Anytime anywhere :slight_smile:

BTW, please skip the (certainly not an MS* one)
remark - then it will also sound more serious…

Cheers–
val it = ("?NOQ of the Sun", “Johnny Andersen”,
[“anoq at vip.cybercity.dk”, “anoq at berlin-consortium.org”,
“anoq at diku.dk”], “http://users.cybercity.dk/~ccc25861/”)
: cyberspacename * meatspacename * email list * homepage URL

Do you mean cross-compiling to Win* from Linux? I really need to
see apps. work on Win* before committing to SDL, becuase the
game must run on Win*. I’m in the phase now where I have to
tell my customer yes or no if I can do the project (ASAP :),
and if I say yes, I will get in trouble if I can’t do it…

That should work. Grab the appropriate cross-compiler packages from:
http://www.devolution.com/~slouken/SDL/Xmingw32/

Win32 is a notoriously unstable development environment when using the
Cygnus tools natively. Cross-compilers are often preferred for that
reason. Unfortunately, it’s rather hard to debug using GNU tools on
Win32. For that reason, I develop most of my Win32 apps using SDL on
Linux, and then do a quick port to Win32. If you use SDL for your
interface, and don’t use any funky UNIX features like signals, then
that should work pretty well for you.

Note that you need to add “target=win32” when cross-compiling the SDL
demos.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

On a more practical note - if I’m going to release this game
commercially it must fit on a single floppy disk - including
graphics etc. So I don’t think there’s room for the
SDL source-code on the disk. Since it’s under LGPL
and LGPL says that the source-code should be as
easily accessible as the binary files, I would like to
know if you think it’s acceptable if I put a textfile
on the floppy disk telling that the game has been developed
using SDL and including a link to your web-page.

That’s fine, as long as you also let people know where SDL can be found
if they contact you directly. (In case the web page moves, etc.)

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Sam Lantinga wrote:

On a more practical note - if I’m going to release this game
commercially it must fit on a single floppy disk - including
graphics etc. So I don’t think there’s room for the
SDL source-code on the disk. Since it’s under LGPL
and LGPL says that the source-code should be as
easily accessible as the binary files, I would like to
know if you think it’s acceptable if I put a textfile
on the floppy disk telling that the game has been developed
using SDL and including a link to your web-page.

That’s fine, as long as you also let people know where SDL can be found
if they contact you directly. (In case the web page moves, etc.)

Sounds good - I’ll do that… thanks!

That should work. Grab the appropriate cross-compiler packages from:
http://www.devolution.com/~slouken/SDL/Xmingw32/

Win32 is a notoriously unstable development environment when using the
Cygnus tools natively. Cross-compilers are often preferred for that
reason. Unfortunately, it’s rather hard to debug using GNU tools on
Win32.

Real men don’t use debuggers - they write test-suites ;-D

For that reason, I develop most of my Win32 apps using SDL on
Linux, and then do a quick port to Win32. If you use SDL for your
interface, and don’t use any funky UNIX features like signals, then
that should work pretty well for you.

Note that you need to add “target=win32” when cross-compiling the SDL
demos.

Thanks - I’ll try that later today… BTW, the Win32 (GCC) SDL version
0.8.10 gives the same errors as the 0.9.9 one. But if crosscompiling
works - then it’s no problem. I agree that Win* is an unstable
development environment - and annoying too :slight_smile:

Cheers–
val it = ("?NOQ of the Sun", “Johnny Andersen”,
[“anoq at vip.cybercity.dk”, “anoq at berlin-consortium.org”,
“anoq at diku.dk”], “http://users.cybercity.dk/~ccc25861/”)
: cyberspacename * meatspacename * email list * homepage URL