Hello. As of recent, I am very very frustrated with SDL2. Out of options here, so looking from some help from someone knowledgeable. I'm trying to get this darn thing working on Windows 8.1.
I had no problems using the first SDL on Windows 7 which went by with a breeze. However, SDL2 is just not the same case.
I'm following the tutorials on "
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/index.php" using the most recently updated codeblocks + minGW32 release. I've also tried it on Orwell Dev C++ + minGW32.
However, something very very odd is happening, something I've never before seen in programming. My compiler is not giving me any errors. However, when the program runs, nothing happens. A window should be created and delayed for a few seconds. I've also tried the part 2 tutorial to show an image, and again, nothing happens.
-I've made sure that neither program is blocked by Windows Firewall and ran the program and the .exe as an administrator.
-The compiler gives no errors.
-SDL2.dll is in the folder of the .exe.
-I've downloaded SDL2.0.3 from the link on the website and downloaded and applied the fix for that one wonky .h file that gives compiler errors in SDL2.0.3 but not SDL2.0.0 downloaded at
https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h
-I've added the lib and include folder in the Compiler Options for SDL2.0.3.
-I've added the linker string: -lmingw32 -lSDL2main -lSDL2 (also tried -lmingw32 -lSDL2 -lSDL2main and like 10 other things found on forums).
-I've tried using both the Debug and the Release compilers.
-I've tried building the program as a GUI application and a Console application. In SDL1, I compiled as a GUI application. In SDL2, this simply compiles, but when ran, it does absolutely nothing. When ran as a console application, a console windows pops up, the program stops responding, and then the console shows Process exited after 6.357 seconds with return value 255.
I've followed all instructions exactly using both Code::Blocks and then Dev C++ IDE and I still am not getting anything, same results. Been working at and googling this for 2 days. What in god's name is happening to cause me all this stress?
If you have any suggestions or have experienced this tragedy, please help! T.T
The code is very basic as shown:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
//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;
}
|
This is the compiler output from Dev C++:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Compiling Project Changes...
|
- Project File: C:\Users\Giovanni\Desktop\test\GioGame\GioGame.dev
- Compiler Name: MinGW GCC 4.8.1 32-bit Debug
Building makefile...
--------
- Filename: C:\Users\Giovanni\Desktop\test\GioGame\Makefile.win
- Output File: C:\Users\Giovanni\Desktop\test\GioGame\GioGame.exe
Processing makefile...
--------
- Makefile Processor: C:\Program Files (x86)\Dev-Cpp\MinGW32\bin\mingw32-make.exe
- Command: mingw32-make.exe -f "C:\Users\Giovanni\Desktop\test\GioGame\Makefile.win" all
g++.exe -c 01_hello_SDL.cpp -o 01_hello_SDL.o -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.8.1/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.8.1/include/c++" -I"C:/Users/Giovanni/Desktop/test/SDL2.0.3/include/SDL2" -g3
g++.exe 01_hello_SDL.o -o GioGame.exe -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/mingw32/lib" -L"C:/Users/Giovanni/Desktop/test/SDL2.0.3/lib" -static-libstdc++ -static-libgcc -lmingw32 -lSDL2main -lSDL2 -g3
Compilation Results...
--------
- Errors: 0
- Warnings: 0
- Output Size: 143.41796875 KiB
- Compilation Time: 2.86s |