I cannot for the life of me figure out what is wrong. I've followed the tutorial here: http://lazyfoo.net/SDL_tutorials/lesson01/windows/mingw/index.php
I cannot get g++ to compile. I receive the following error:
testgame.c:1:21: fatal error: SDL/SDL.h: No such file or directory
#include "SDL/SDL.h"
Here is the code in the file:
#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Quit SDL
SDL_Quit();
return 0;
}
Directories:
C:\MinGW\include\
- This is where I placed the SDL folder with *.h files
C:\MinGW\lib\
- This is where I placed all the lib files for SDL
I've also placed the SDL.dll in my file/executable directory.
I'm using the following to compile:
g++ -o testgame.exe testgame.c -lmingw32 -lSDLmain -lSDL
I have no idea what I could be doing wrong. I've searched all over and nothing has worked so far. Please help!
Thanks, Travis
Update:
Changing the include statement to:
#include "C:/MinGW/include/SDL/SDL.h"
Fixes the initial error but now I receive:
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDLmain
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL
collect2.exe: error: ld returned 1 exit status
@cat Suggested the following:
g++ -o testgame.exe testgame.c -lmingw32 -L.SDLmain -lSDL
However this returned this error:
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL
@vonaka Suggested:
g++ -o testgame.exe testgame.c -lmingw32 -LC:/MinGW/lib/
However, this returned multiple errors.
I've figured out how to fix this problem. I placed all the relevant SDL and/or SDL2 files into a separate folder in C:\ called mingw_dev_lib. Then I explicitly stated the paths to the lib folder and the include folder inside this new directory with the following:
gcc testgame.c -IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o testgame.exe
The compilation was successful after these steps. It is strange though that it wouldn't compile when trying to access these files and the standard C:\MinGW directories.