Having trouble with SDL, KDevelop and Linux

Started by
8 comments, last by jeroenb 17 years, 5 months ago
So now that I'm with linux, I said, lets start coding. Ok, tried out Eclipse didnt work out for me.... Tried out KDevelop, hello world was really easy to make. Well layed out and stuff. So I'll stick with KDevelop. Now, it's time for SDL. I check to see what SDL I have (from the package manager) and it seems SDL, SDL_image, SDL_net, SDL_ttf, and anything else relating to SDL is installed. So, I though, "I'll just use the SDL template KDevelop provides". Well, use it, compile and get undefined errors. The interesting part is that they are undefineds. I include "SDL.h", and it doesn't tell me it can't find it.... So I'm assuming it finds it. Anyways, after that it does find the declarations for any of the functions. Not only that, but NULL is undefined as well..... :/ I'm new to all this, so thanks to anyone that helps! [wink]
Advertisement
You need to get the options to the linker right. You need at least -lSDL, and possibly a whole lot more (-lGL, -lX11...).

There is a command to get all compile and link flags to use in your project, it's called sdl-config.

Good luck.
-- Top10 Racing Simulation needs more developers!http://www.top10-racing.org
Quote:Original post by johdex
You need to get the options to the linker right. You need at least -lSDL, and possibly a whole lot more (-lGL, -lX11...).

There is a command to get all compile and link flags to use in your project, it's called sdl-config.

Good luck.


I know, but these are undeclareds. They have nothing to do with the libraries (it doesn't even get as far as linking since there are undeclareds).

And also, I tried the sdl-config thing with the --version flag, as well as the --libs (I think that was it) flag.... But the command line told me there was no such command. It seems like SDL isn't installed, even though the package manager says it is. And didnt XGL use SDL? Because XGL works fine.
Generate a minimal example, and post the actual errors.
Quote:Original post by Kylotan
Generate a minimal example, and post the actual errors.


I did say the actual errors. Anything relating to SDL is undeclared. Thats it, nothing else. I thought it would give me undeclareds if it didnt find sdl.h, but it never said it didn't exist...

But, just in case:
#include "SDL.h"int main(int, char*[]) {    SDL_Init(SDL_INIT_VIDEO); // undeclared identifier    SDL_Quit(); // another undeclared identifier}
When I get what you are decribing in Dev C++, it means that I've '#include'd them, but I haven't linked to them properly. In my linker settings I must do this: Project->Project Options->Parameters and enter into the linker box the following defines:

"../My Programs/SDL_gfx/SDL_gfx.o"    <- For my lib 'SDL_gfx'-lmingw32 -lSDLmain -lSDL             <- Basic SDL-lSDL_input -lSDL_image               <- My 'SDL_input' lib, and the downloadable 'SDL_image'-lSDL_ttf -lSDL_mixer -lSDL_gfx       <- Downloadable 'SDL_ttf' and 'SDL_mixer', and my 'SDL_gfx'
Perhaps a simular thing is neccesary in your IDE? Also, make sure you put any .o files before the linker ('-lSDL_mylib') files.
Thanks everyone, I've seem to have fixed it.

-downloaded SDL-devel from YaST and installed
-messed with my ide for half an hour to figure out what goes where
-figured stuff out, slapped in `sdl-config --libs` into the linker
-built and ran my program =)

Does anyone know how to tell KDevelop where to look for SDL? Because right now I have to use SDL/SDL.h, which isn't all that great.
Quote:Original post by agi_shi
Does anyone know how to tell KDevelop where to look for SDL? Because right now I have to use SDL/SDL.h, which isn't all that great.


I'm afraid that's the most portable way to include SDL. :)

Add `sdl-config --cflags` to the compiler options and you can do the #include "SDL.h".
EDIT:
Found this site explaining how to setup SDL with KDevelop.
And SDLs FAQs might help you (Do I #include <SDL.h> or <SDL/SDL.h>?)

[Edited by - baumep on October 20, 2006 3:42:03 AM]
baumep
You dont have to use SDL/SDL.h, but then you must add the complete path to the sdl includes in your project settings. Although the SDL/SDL.h is indeed the default way for including SDL stuff. It has always worked for me in KDevelop.

Crafter 2D: the open source 2D game framework

?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]

This topic is closed to new replies.

Advertisement