SDL + VisualC++ 5?

How do I go about making SDL apps in VC5??

I’ve done DX apps in VC before, nut since I use Linux oftenly and am
thinking about getting a Mac, I’d lite my progs. to work on them all.

The thing I don’t know is how to ‘install’ the includes and libs… And what
type of app do I make?? A console app? Or a win32? But then linux would
complain about the win_main function wouldn’t it??

Is there any example program using SDL and VC???

Oscar Campbell

How do I go about making SDL apps in VC5??

The thing I don’t know is how to ‘install’ the includes and libs…

Just unpack them anywhere, and add the include and library paths to your
project. Read the file README.VisualC in the main SDL directory for
specific directions.

And what type of app do I make?? A console app? Or a win32?

A win32 app.

But then linux would complain about the win_main function wouldn’t it??

The SDL library contains a WinMain() function that calls your main function.

Is there any example program using SDL and VC???

All of the test programs should compile with SDL and VisualC.
If you’re asking for a pre-built project and example, you might send
e-mail to Paulus Esterhazy and he may be able to
help you.

Good luck!

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

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

How do I go about making SDL apps in VC5??

I’ve done DX apps in VC before, nut since I use Linux oftenly and am
thinking about getting a Mac, I’d lite my progs. to work on them all.

The thing I don’t know is how to ‘install’ the includes and libs… And what
type of app do I make?? A console app? Or a win32? But then linux would
complain about the win_main function wouldn’t it??

Just make a new Win32 App (not console, though it might work, too) or use
an existing one and add the library that you can download from SDL downloads
page, it should still be working for 0.8.*.
If you want to use a newer version like the current snapshot, unzip the
visualc.zip
file in the SDL directory and a project file will come out of it. Open the
project file,
do the things listed in Readme.VisualC ( = copy the dx6 libs in the right
places )
and make the library.
Now you’ve got the library which can be simply linked into your program
(e.g.
an SDL demo, Warp).
The file that has your main() function should always #include <SDL.h> which
#defines a macro that changes main() to RunMain() which in place is called
by WinMain() (defined in the static library)-

Note that you should not use Multithreaded DLL compile option or at least
compile
the library with that option, too for otherwise, it will crash badly.

Is there any example program using SDL and VC???
Every demo from SDL_demos should work fine. I haven’t tried
all of them, ususally you just have to #include some header file.
If you can’t compile a demo, drop a mail.

Oscar Campbell

hope that will help you (did I miss anything? I don’t want to miss a thing!)
Please send me an e-mail if this works so I can be sure…

enjoy
~ Paulus Esterhazy (@Paulus_Esterhazy)

I’m also having problems compiling for VC5.

I have a program that is currently written for VC5, but I’d like to port
it.

The Win32 zip files that I downloaded contained no Readme.visualC file.

In attempting to compile and link the SDL libraries, I made this as my
main file:

//*********

#include <sdl.h>

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

//*********

My preprocessor #defines are only: _WIN32,_DEBUG,_WINDOWS

The following is captured directly from compiler output:

--------------------Configuration: sdltest - Win32 Debug--------------------
Linking…
sdllib.lib(winmain.obj) : error LNK2001: unresolved external symbol
_RunMain
Debug/sdltest.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

sdltest.exe - 2 error(s), 0 warning(s)

Any suggestions? I’d REALLY like to port my game to Linux, et. al.


extern “C”
{
#include <SDL.h>
}

// …

int mymain(int,char**);

extern “C” {
int RunMain( int argc, char **argv )
{
return mymain(argc,argv);
}
}

int mymain(int argc, char *argv[])
{
SDL_Init(…);
//…
cout << “Hello World\n”;
}

It looks messy, but it works just fine.

Try defining WIN32 (with no underscore)
If your program is C, try renaming the extension of your files from .CPP to .C
If your program is C++, you’ll need to do some wierd hacks because the SDL
library is written in C, and it wants to call your main function directly.
(Win32 and MacOS only) Let me know if this is the case, and I’ll work with
you to get the cleanest solution.

Please send me private e-mail if this works.

My preprocessor #defines are only: _WIN32,_DEBUG,_WINDOWS

The following is captured directly from compiler output:

--------------------Configuration: sdltest - Win32 Debug--------------------
Linking…
sdllib.lib(winmain.obj) : error LNK2001: unresolved external symbol
_RunMain
Debug/sdltest.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

sdltest.exe - 2 error(s), 0 warning(s)

Any suggestions? I’d REALLY like to port my game to Linux, et. al.

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

Well, I understood how to do it after the first reply. I’m glad to see the
great help support there is for SDL, it makes you realize it’s worth
sticking too.

Thanks for all the help.

Oscar Campbell

  1. you need to sorround #include <SDL.h> with extern “C” { }
    'cause it’s not in the header file and the compiler complains
    about different linkage settings otherwise.

This shouldn’t be necessary. If it is, please send me the compiler output
privately so I can see what needs fixing.

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

Well, I understood how to do it after the first reply. I’m glad to see the
great help support there is for SDL, it makes you realize it’s worth
sticking too.

smile Thanks, that’s what we all are for. :slight_smile:

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

Thanks, it compiles now.

I agree with Oscar. The speedy response on this mailing list is
wonderful. I’ll will attempt an SDL port of our game.

This is what worked for me:
(#defines) _WIN32,_DEBUG,_WINDOWS
//**********
extern “C” {
#include <SDL.h>
}

int main(int argc, char *argv[]) {
return 0;
}
//**********On Sat, 21 Nov 1998, Sam Lantinga wrote:

  1. you need to sorround #include <SDL.h> with extern “C” { }
    'cause it’s not in the header file and the compiler complains
    about different linkage settings otherwise.

This shouldn’t be necessary. If it is, please send me the compiler output
privately so I can see what needs fixing.

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


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

I’m wondering whether you could just rename your source file to be a c file,
eg: source.c. I wonder whether this is a cleaner solution for those
programming in pure c.

I’m wondering whether you could just rename your source file to be a c file,
eg: source.c. I wonder whether this is a cleaner solution for those
programming in pure c.

Yup, that would work as well.

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