Using SDL in Microsoft Visual 2010

I was attempting to do a tutorial from this link.

http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet2010e/index.php


I downloaded the SDL-1.2.14 version and everything seemed to work. I have no errors when I run the build but as it tries to open i get this error.

"This application has failed to start becasue SDL.dll was not found. Re-installin the application may fix this problem."

I went through everything again to make sure I followed each step and from what I can tell I have not missed any steps. Has anyone else had any trouble with this? I was very eager to get learn and start coming up with my own ideas but this roadblock is eating at me.

If theres anything else I can do to explain my situation let me know...

Thanks in advance.
Put the SDL.dll in the directory where the *.exe of your program is
Thank you! It looks like that worked but now im onto my next error... lol.

Unhandled exception at 0x6812a21b in SDL tutorial.exe: 0xC0000005: Access violation reading location 0x00000004.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "SDL.h" int main( int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Quit SDL SDL_Quit(); return 0; }
int main ( int argc, char* args[])
{
#include "SDL.h"
int main (int argc, char* args []);
	SDL_INIT_EVERYTHING;
	SDL_Surface* hello = NULL;
	SDL_Surface* screen= NULL;
	SDL_INIT_EVERYTHING;
	SDL_SetVideoMode (640, 40, 32, SDL_SWSURFACE);
	SDL_LoadBMP ("hello.bmp");
	SDL_BlitSurface (hello, NULL, screen, NULL);
	SDL_Flip( screen);
	SDL_Delay (20000);
	SDL_FreeSurface( hello);
	SDL_Quit();
	return 0;
}


There is a green arrow pointing to the "SDL_Flip (screen);" and the error allowed me to break or continue.

Does the picture also have to be saved in a certain file?
Last edited on
Well, I don't know what's wrong, because I've never used SDL (I use openGL). But I get a VERY similar error when I try to read/reference information from an array spot that doesn't exist. here's an example:

1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

int main() {
    int myArray[10];     //allocate an array of 10 spots
    myArray[10] = 6;     //array spot (10) is 6
    cout << myArray[11]; //this array spot doesn't exist!
    cin.get();                //pause the program to observe the output
}


I don't know how much this helps, if this helps at all; however, it may be able to help you diagnose the problem :)
Read the tutorial more carefully. The code you posted is different from the one in the tutorial.
Thanks i think i edited the code and I'm still not getting any errors until it pulls up the SDL app. It comes up blank and then the error continues to come up.

Unhandled exception at 0x6812a21b in SDL tutorial.exe: 0xC0000005: Access violation reading location 0x00000004.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "SDL.h" int main( int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Quit SDL SDL_Quit(); return 0; }
int main ( int argc, char* args[])
{
	SDL_Surface* hello = NULL;
	SDL_Surface* screen= NULL;
	SDL_INIT_EVERYTHING;
	SDL_SetVideoMode (640, 40, 32, SDL_SWSURFACE);
	SDL_LoadBMP ("hello.bmp");
	SDL_BlitSurface (hello, NULL, screen, NULL);
	SDL_Flip( screen);
	SDL_Delay (20000);
	SDL_FreeSurface( hello);
	SDL_Quit();
	return 0;
}
This is how it's supposed to look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "SDL.h"
int main ( int argc, char* args[])
{
	Start SDL SDL_Init( SDL_INIT_EVERYTHING );
	SDL_Surface* screen= SDL_SetVideoMode (640, 40, 32, SDL_SWSURFACE);
	SDL_Surface* hello = SDL_LoadBMP ("hello.bmp");
	SDL_BlitSurface (hello, NULL, screen, NULL);
	SDL_Flip( screen);
	SDL_Delay (20000);
	SDL_FreeSurface( hello);
	SDL_Quit();
	return 0;
}
Hope you understand what you did wrong. I don't know SDL so no further question please. I heard that SFML http://www.sfml-dev.org/ is better though.

And yes. "hello.bmp" must be in the working directory (normaly the *.exe directory), too.
Topic archived. No new replies allowed.