• Advertisement
Sign in to follow this  

Problems getting started, "SDL2/SDL.h: No such file or directory"

This topic is 1494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Im relativly new to C++, was going to moving on to SDL My goal was to create a simple 2D game having a movable characters and some obstacles drawn on the screen and move on from there.

 

I followed the guide under tutorials on SDLs page on how to setup on Code::Blocks. 

 downloading all the files and following the steps...

 

I have put theese lines under Search directories:

 

Compiler:

C:\SDL\SDL2_mixer-2.0.0\x86_64-w64-mingw32\include\SDL2

C:\SDL\SDL2-2.0.1\i686-w64-mingw32\include\SDL2

C:\SDL\SDL2_image-2.0.0\i686-w64-mingw32\include\SDL2

 

Linker:

C:\SDL\SDL2_mixer-2.0.0\x86_64-w64-mingw32\lib

C:\SDL\SDL2-2.0.1\i686-w64-mingw32\lib

C:\SDL\SDL2_image-2.0.0\i686-w64-mingw32\lib

 

and put the lines -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer under Linker settings > Other linker options. As I understand this is for 32 bit, I would prefer the 64 hower dont know how to install it.

 

 

I downloaded the project in that tutorial also (SDL001), build and run does work. But however as soon as I edit something like just adding a comment. It gives an error and stop working! :

 

"SDL2/SDL.h: No such file or directory"

 

I downloaded some other tutorials from the same guy, with various results. I been trying to search the web on how to solve this problem without any results. Someone have any idea on what Im missing?

 

 

/Thank you

Edited by Dude_sWe

Share this post


Link to post
Share on other sites
Advertisement
This is your problem:
 

I have put theese lines under Search directories:
 
Compiler:
C:\SDL\SDL2_mixer-2.0.0\x86_64-w64-mingw32\include\SDL2
C:\SDL\SDL2-2.0.1\i686-w64-mingw32\include\SDL2
C:\SDL\SDL2_image-2.0.0\i686-w64-mingw32\include\SDL2

The compiler is going to look for the headers you include by appending them to every path on the search path until it comes up with it. So that means that when you #include "SDL2/SDL.h", then the compiler is going to be looking for "[background=#f7f7f7]C:\SDL\SDL2-2.0.1\i686-w64-mingw32\include\SDL2\SDL2\SDL.h"[/background]. Obviously, that doesn't exist.

So remove the trailing [background=#f7f7f7]\SDL2[/background] from all of your include paths and it should work. Alternatively, you can just #include "SDL.h", but I don't recommend it. Edited by Aldacron

Share this post


Link to post
Share on other sites

Did you remember to add the SDL folder to the Search Directories tab?

Did you test including "SDL2.h" without the folder?

Edited by dejaime

Share this post


Link to post
Share on other sites

Oh thanks guys! It works, Yea it was one to many SDL2 directories! I just used  #include "SDL.h" since that was what the rest of the tutorials had...

 

And I had problems with the tutorial SDL2 0 RPG Game tutorial part 1 (SDL301). Error about zlib1 not found. I simply put the zlib1 into the the game directory. I suppose it was the right thing to do? Just feels a bit strange since I dont know if my program works the way it should or if the tutorialguy forgot to put it in somehow eventhought it works fine for him in the video?..

 

 

And I tried to change the the compiler and linker folder to the 64bit, somehow that was not enought. Is there any simpel way to get 64 bit? Elseway Im happy it works now and I suppose I'll be able to change to 64bit in the future when I find a tutorial or something.

Edited by Dude_sWe

Share this post


Link to post
Share on other sites

Oh about the 64bit-ness, chances are your compiler is 32bit, which is why 64-bit SDL won't work.  

Cant help you with a solution though, as I just decided to settle with 32bit.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement