code in question
/
*This source code copyrighted by Lazy Foo' Productions (2004-2015)
and may not be redistributed without written permission.*/
//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] )
{
//The window we'll be rendering to
SDL_Window* window = NULL;
//The surface contained by the window
SDL_Surface* screenSurface = NULL;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//Create window
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//Get window surface
screenSurface = SDL_GetWindowSurface( window );
//Fill the surface white
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
//Update the surface
SDL_UpdateWindowSurface( window );
//Wait two seconds
SDL_Delay( 2000 );
}
}
//Destroy window
SDL_DestroyWindow( window );
//Quit SDL subsystems
SDL_Quit();
return 0;
}
pretty sure the code i copied and pasted into the 'other linked libraries' right hand window was
erroneous for me ... since all my sdl stuff is somewhere else ... mydocuments tbp
hence the code ...
-lmingw32 -lSDL2main -lSDL2
. copied from tut
(i've never seen this '-object notation before)
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/index.php
is wrong yeah ?
look i really want to help you. My english is not the best so i write in short pointy style to make my points clear...
It's not really an SDL problem though is it ? ... it's a problem linking a lib to code blocks ...
1) according this error:
C:\Users\Owner\Documents\uz01_hello_SDL-5\01_hello_SDL\01_hello_SDL.cpp: In function 'int SDL_main(int, char**)':
C:\Users\Owner\Documents\uz01_hello_SDL-5\01_hello_SDL\01_hello_SDL.cpp:15:2: error: 'SDL_Window' was not declared in this scope
SDL_Window* window = NULL;
you have a compiling not a linking problem
2) according this line:
mingw32-g++.exe -Wall -std=c++11 -g -std=c++11 -IC:\Users\Owner\Documents\sdlunzipped\SDL-1.2.15\include\SDL -c C:\Users\Owner\Documents\uz01_hello_SDL-5\01_hello_SDL\01_hello_SDL.cpp -o obj\Debug\Users\Owner\Documents\uz01_hello_SDL-5\01_hello_SDL\01_hello_SDL.o
You have corretly added the include paths so that the compiler can find the include files
according this code:
you include some sdl header, but you get some errors, so i presume that your sdl installation is broken, or you mix sdl with sdl2... Both are not problems with codeblocks, but with sdl
i am not familiar with sdl so i googeled for two seconds and found this:
2) http://stackoverflow.com/questions/12695719/sdl-window-does-not-name-a-type or use google future, you have now a sdl problem, not a code blocks problem and so this is the wrong forum to ask this questions
and so Tim came to this conclusion
Please read the rules before you are banned!
http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
If you have found out, that you are using sdl2 headers, but want to use sdl1 headers, and you don't know where to set the right path so the compiler can find your sources, you can ask this here (but you can set include paths as there are set some in 2) ) ... but for other questions, like "error: 'SDL_Window' was not declared in this scope" we have to ask you to search help in a other forum. They will tell you: "you have to include xy" or "you have to add zq to your compiler search directories". Then you can come back and ask "how do i add zq to my compiler search directories?" and we will happily help you...
greetings