VC++ Project for SDL?

Has anyone made a Microsoft Visual C++ 5 project for SDL? I ask because
I have a rather large nubmer of projects already set up in VC++ and
Source Safe that I’d like to try to convert over to SDL (from MGL) and
it would be easier than converting all those projects to work in the GNU
development environment on my work PC. I have successfully compiled the
source into a DLL under VC but the result exited immediately (at least
it didn’t crash) when I tried one of the example programs. I thought
before I delved into a long debugging session, I’d ask to see if someone
had already done this. Thanks in advance.

I don’t think anybody has done this yet.
A few tips on SDL and building:

Get the latest SDL source (0.8c) from the developer's web page
http://www.devolution.com/~slouken/SDL/develop.html

Define _BUILDING_SDL when you are building the dynamic library

Link your project with the source files in src/stub and src/stub/win32
(like winmain.c)

Include "SDL.h" in your source file containing main(), so that it
can be redefined and the SDL main() can be used.  If you use WinMain(),
grab winmain.c from SDL/src/stub/win32 and modify that to suite your
needs and use it instead.

I tried a very long time ago to get SDL working with VC++, but it didn’t
work immediately, and I didn’t have time to look into it (had to give VC++
back to the owner). SDL has improved immensely since then, so should be
easier to build in the VC++ environment.

You might even be able to get away with linking your project with the
load.c and winmain.c included with SDL and then dynamically load a prebuilt
DLL (which I can provide)

Please let me know when it works for you! :slight_smile:

Thanks,
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Has anyone made a Microsoft Visual C++ 5 project for SDL? I ask because
I have a rather large nubmer of projects already set up in VC++ and
Source Safe that I’d like to try to convert over to SDL (from MGL) and
it would be easier than converting all those projects to work in the GNU
development environment on my work PC. I have successfully compiled the
source into a DLL under VC but the result exited immediately (at least
it didn’t crash) when I tried one of the example programs. I thought
before I delved into a long debugging session, I’d ask to see if someone
had already done this. Thanks in advance.

-Todd Allendorf

On 08.30.98 12:40 AM Sam Lantinga said…

I don’t think anybody has done this yet.

Hi,
Well in fact I’ve succeeded in compiling the fire and the warp
example and running it with the gnu-c dll which worked fine.
Then I happily ported my own small game to sdl but it crashed
every time I tried to write into sdl_screen->pixels…
Anyway, I don’t think there’ll be a lot of problems to make
sdl run with VC++ (although I personally don’t do windows
programming - I use Watcom and DOS4GW). I had to change
some gcc-specific things in sdl_mangle.h. This was version 0.7.
I’ll try to make it run with the most recent version…

Btw, I find it very important to make SDL run with a 'normal’
win32 compiler because it’s certainly annonying to compile
the program in linux and then reboot and try it out in windows.—
Paulus Esterhazy (paulus.esterhazy at rhein-neckar.de)
Author of … nothing

Hi,
Well in fact I’ve succeeded in compiling the fire and the warp
example and running it with the gnu-c dll which worked fine.

Great! :slight_smile:

Then I happily ported my own small game to sdl but it crashed
every time I tried to write into sdl_screen->pixels…

You probably need to lock the surface…
if ( SDL_MUSTLOCK(surface) ) {
if ( SDL_LockSurface(surface) == 0 ) {
DrawSurface(surface);
SDL_UnlockSurface(surface);
} else {
/* Hum… don’t draw this frame? */;
}
} else {
DrawSurface(surface);
}

You don’t strictly need the SDL_MUSTLOCK() macro. You can lock the
surface anyway, but it avoids the overhead of a function call and a
few tests.

Btw, I find it very important to make SDL run with a 'normal’
win32 compiler because it’s certainly annonying to compile
the program in linux and then reboot and try it out in windows.

I completely agree. If you don’t have the money for a compiler though,
developing under Linux – and debugging most everything under Linux –
is a very attractive option. :slight_smile:

I’d love to see the source changes necessary to get the name mangling
right under VC++.

Thanks Paulus!

-Sam Lantinga				(slouken at devolution.com)--

Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Btw, I find it very important to make SDL run with a 'normal’
win32 compiler because it’s certainly annonying to compile
the program in linux and then reboot and try it out in windows.
Why don’t you try to use the normal mingw32 gcc package. This is a gcc
compiler that works under a win32 enviroment (no cross compiler).

I’ve used this to test some programs that would fail in a win32 env but
not in Unix.

grt,

Btw, I find it very important to make SDL run with a 'normal’
win32 compiler because it’s certainly annonying to compile
the program in linux and then reboot and try it out in windows.
Why don’t you try to use the normal mingw32 gcc package. This is a gcc
compiler that works under a win32 enviroment (no cross compiler).

This environment isn’t very stable under Win95.
It works great under WinNT, but is still hard to debug.

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Sam Lantinga wrote:

Btw, I find it very important to make SDL run with a 'normal’
win32 compiler because it’s certainly annonying to compile
the program in linux and then reboot and try it out in windows.
Why don’t you try to use the normal mingw32 gcc package. This is a gcc
compiler that works under a win32 enviroment (no cross compiler).

This environment isn’t very stable under Win95.
It works great under WinNT, but is still hard to debug.

The actual mingw32 tools are very stable. The cygwin32 tools aren’t. So the
obvious suggestion is ‘don’t use the CYGWIN tools! eg. bash, etc.’ Go grab
Mumit Khan’s EGCS mingw32 distribution. Works a charm. Just don’t use the
cygwin tools.
The only disadvantage of this is that you can’t use bash under mingw32 (to
run configure.sh). But then bash is VERY slow under windows anyway, so why
not just use some kind of batch file (all the batch file has to do is
rename an included Makefile.win to Makefile. Or something like that…)

:slight_smile:
Peter