Can anybody use SDL? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anybody use SDL?

Hi all. Followibg on from the last question, I have dumped the course. I feel I have learnt lot more through this app and on YouTube! Thank you. I am back to SDL issues now though. I have finally got a working setup but now I have Syntax errors and I cannot see why. It specifically does not like SDL_Surface and SDL_Texture. Any ideas would be appreciated. Thank you.

10th Aug 2017, 3:32 PM
Richard Appleton
Richard Appleton - avatar
20 Answers
0
Thanks for replying. Yes, that bit is fine, but on compilation I get a syntax error saying "missing ; before *". There are also two other errors. I will give you more details when I am home.
10th Aug 2017, 3:54 PM
Richard Appleton
Richard Appleton - avatar
+ 5
10th Aug 2017, 4:16 PM
jay
jay - avatar
+ 5
I would start a new project and get sdl working with the hello world example first. Then start pulling code over from the cave story. Is cave story your code? or from the course?
13th Aug 2017, 11:48 PM
jay
jay - avatar
+ 4
Just checking You did copy the dll to the source folder right. also it will need a copy in the debug directory (where the resulting exe from compilation resides) Otherwise no.. it does not sound an easy fix. It should be quite simple as *Download sdl-devel from https://www.libsdl.org/download-2.0.php *extract files. *create a new project *configure your ide - includes/libraries/dependancies *copy required dlls to your projects directory. thats it.
13th Aug 2017, 3:03 AM
jay
jay - avatar
+ 4
link to vid i will look
13th Aug 2017, 11:54 PM
jay
jay - avatar
14th Aug 2017, 12:07 AM
jay
jay - avatar
+ 3
Are you declaring them correctly? They have to be pointers. Ex. SDL_Texture* texture, not SDL_Texture texture
10th Aug 2017, 3:48 PM
aklex
aklex - avatar
+ 3
^^ @aklex: so true.
10th Aug 2017, 5:23 PM
jay
jay - avatar
+ 3
looks like sdl is not setup correctly follow the instructions at lazyfoo for your compiler.
12th Aug 2017, 4:18 AM
jay
jay - avatar
+ 3
well SDL_Surface and SDL_Texture being undeclared identifiers says to me not setup correctly. As these are globals if you have included #include <sdl.h> Even missing a tiny step will cause it not to be setup correctly
12th Aug 2017, 5:07 AM
jay
jay - avatar
+ 3
You will need two copies (one in with main, another with exe) unless you put sdl in your system32/wow64 folder. anyway.. re: SDL_image. you will need to setup this also in your ide (include/lib dirs and dependancy options) and copy the relevant .lib/.dll files to your working directory as they differ from the main sdl setup.
13th Aug 2017, 4:33 AM
jay
jay - avatar
+ 2
If you could provide the relevant source code it would be helpful :p
10th Aug 2017, 4:39 PM
aklex
aklex - avatar
+ 2
Aaarggghhhh!! So I have put the dll files into the debug folders and the SDL Trainer is working fine. Howevwr, I am still getting the same errors on the CaveStory and there is no difference in the settings. I just don't get it at all. I am tempted to totally delete all this Cave Story stuff and start it again. Is there any way I can use the SDL project as a template as I know this one definitely works.?
13th Aug 2017, 11:44 PM
Richard Appleton
Richard Appleton - avatar
+ 2
yes. it was fine until episode 4 https://youtu.be/yq_00MAp0Xw
14th Aug 2017, 12:08 AM
Richard Appleton
Richard Appleton - avatar
+ 1
Sorry. Couldn't get on my computer yesterday. Here are the problems: graphics.flip; generates the following error: Graphics::flip : Non standard syntax; use & to crwate a pointer to member. The Graphics::flip is as follows: SDL_RenderPresent(this -> renderer); SDL_Surface * loadimage(const std::string &filepath); generates the following three errors: syntax error: missing ; before * missing type specifier. int assumed. c++ does nit support default int. unexpected token preceding ; void blitsurface(SDL_Texture * source, SDL_Rect* SourceRectangle, SDL_Rect* DestinationRectangle); generates the following error: Syntax Error: identifier SDL_Texture std::map<std::string, SDL_Surface*> Spritesheet; generates the following errors SDL_Surface: undeclared identifier syntax error > std::map: too few template arguments.
12th Aug 2017, 3:51 AM
Richard Appleton
Richard Appleton - avatar
+ 1
Hi Jay. i have actually set up all those links correctly. I am going to go through the tutorial on LazyFoo and see if I can work out the problem. Thanks.
12th Aug 2017, 4:51 AM
Richard Appleton
Richard Appleton - avatar
+ 1
Hi Jay. I am absolutely infuriated here!! The SDL Trainer on LazyFoo has the links set uo exactly the same (I have done a side by side comparison on the screen) and compiles with no errors. However, even though it compiles, it will not run!! I get an application error, even when I delete all the code so I just have: int main() { return 0; } However, removing SDL.H from my includes solves the problem, so looks like the error is in that somewhere. Does this sound like an easy fix?
13th Aug 2017, 2:46 AM
Richard Appleton
Richard Appleton - avatar
+ 1
I don't have one in the debug directory. I have it in the same folder as my main.cpp. Is that the wrong place? I also have it in my System 32 folder in to Windows directory. The wierd thing is, it was working fine on the first programme (The Cave Story on Youtube) so I have actually drawn a window. once I added SDL_image, it all went wrong.
13th Aug 2017, 4:12 AM
Richard Appleton
Richard Appleton - avatar
0
it's from the YouTube links that somebody gave me in a previous answer. It's a type along with a programmer sort of thing. I added the CaveStory code into a copy of the SDL Training and ran it, and I am getting the same 8 errors, which makes me think it is a problem with the coding, not the SDL settings.
13th Aug 2017, 11:52 PM
Richard Appleton
Richard Appleton - avatar
0
Hi Jay. Did you get chance to look at this? Is the error in the code? Thank you.
17th Aug 2017, 11:54 AM
Richard Appleton
Richard Appleton - avatar