I downloaded SDL-1.2.2.zip and built the projects, which include the
SDL
libraries and some demos. It all builds without error and the demos I
have tried do work.
Following the instructions in the enclosed document “Using SDL with
Microsoft
Visual C++ 5 and 6” by Lion Kimbro I created a Visual C++ 6.0 project
to
compile the very simple SDL initialization example program in the SDL
documentation. I have been
VERY careful to follow the instructions on setting up the project, to
the letter. I’ve repeated the steps
a few times, gone over them for a couple of days, and the only way I
have been
able to get it to compile and link is with strange voodoo shit. It
goes like
this, here is the c program:
#include “SDL.h” /* All SDL App’s need this */
#include <stdio.h>
int main() {
printf("Initializing SDL.\n");
/* Initialize defaults, Video and Audio */
if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) {
printf("Could not initialize SDL: %s.\n", SDL_GetError());
exit(-1);
}
printf("SDL initialized.\n");
printf("Quiting SDL.\n");
/* Shutdown all subsystems */
SDL_Quit();
printf("Quiting....\n");
exit(0);
}
When I try to compile the project, I get this error message:___________________________________________________________________
--------------------Configuration: VideoTimerA - Win32
Debug--------------------
Compiling…
VideoTimerA.cpp
c:\newsource\videotimera\videotimera.cpp(11) : error C2065: ‘exit’ :
undeclared
identifier
Error executing cl.exe.
VideoTimerA.exe - 1 error(s), 0 warning(s)
Figuring that the problem might be caused by C vs C++ linking
issues, I
renamed by program file with a .c extension instead of a .cpp
extension, I get
this
-------------------Configuration: VideoTimerA - Win32
Debug--------------------
Compiling…
VideoTimerA.c
c:\newsource\videotimera\videotimera.c(4) : warning C4026: function
declared
with formal parameter list
c:\newsource\videotimera\videotimera.c(11) : warning C4013: 'exit’
undefined;
assuming extern returning int
c:\newsource\videotimera\videotimera.c(24) : warning C4716: ‘SDL_main’
: must
return a value
Linking…
VideoTimerA.exe - 0 error(s), 3 warning(s)
So I revert back to the original .cpp file extension, and it compiles
without
error:
--------------------Configuration: VideoTimerA - Win32
Debug--------------------
VideoTimerA.exe - 0 error(s), 0 warning(s)
And it executes without error also.
So I though I had the problem fixed with magic, but then when I add
more C++ files to the project and my own header file I get the same
problems all over again.
What am I doing wrong ? This is making me crazy.
Could perhaps someone send me a really simple plain-vanilla VC++6
project which links SDL and does compile and link reliably, without
error ? Or of course if someone just knows the cause…
Best,
Allen