Having trouble with SDL, KDevelop and Linux

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

Recommended Posts

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]

Share on other sites
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.

Share on other sites
Quote:
 Original post by johdexYou 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.

Share on other sites
Generate a minimal example, and post the actual errors.

Share on other sites
Quote:
 Original post by KylotanGenerate 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}

Share on other sites
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.

Share on other sites
Thanks everyone, I've seem to have fixed it.

-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.

Share on other sites
Quote:
 Original post by agi_shiDoes 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. :)

Share on other sites
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]

Share on other sites
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.

1. 1
2. 2
frob
17
3. 3
4. 4
5. 5

• 20
• 13
• 14
• 76
• 22
• Forum Statistics

• Total Topics
632140
• Total Posts
3004373

×