Sign in to follow this  
nullsquared

Having trouble with SDL, KDevelop and Linux

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 this post


Link to post
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 this post


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

Share this post


Link to post
Share on other sites
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
}


Share this post


Link to post
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 this post


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

Share this post


Link to post
Share on other sites
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. :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this