Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Dude_sWe   Members   -  Reputation: 122

Like
0Likes
Like

Posted 02 December 2013 - 07:25 AM

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. https://www.youtube.com/watch?v=wWGtuc5uqF4 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, 02 December 2013 - 07:29 AM.


Sponsor:

#2 Aldacron   GDNet+   -  Reputation: 3281

Like
0Likes
Like

Posted 02 December 2013 - 08:21 AM

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 "C:\SDL\SDL2-2.0.1\i686-w64-mingw32\include\SDL2\SDL2\SDL.h". Obviously, that doesn't exist.

So remove the trailing \SDL2 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, 02 December 2013 - 08:24 AM.


#3 dejaime   Crossbones+   -  Reputation: 4119

Like
0Likes
Like

Posted 02 December 2013 - 09:25 AM

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, 02 December 2013 - 09:27 AM.


#4 Dude_sWe   Members   -  Reputation: 122

Like
0Likes
Like

Posted 02 December 2013 - 09:57 AM

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, 02 December 2013 - 10:25 AM.


#5 Godmil   Members   -  Reputation: 744

Like
0Likes
Like

Posted 22 December 2013 - 09:08 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS