News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Ubuntu 9.04 SDL linker problem (SOLVED).

Started by peterjoziasse, September 06, 2010, 05:28:46 AM

Previous topic - Next topic

peterjoziasse

EDIT: i found the solution here: http://www.munkyjunky.com/2010/03/ubuntu-codeblocks-opengl/

Hello. I use C::B 8.02. Simple sdl programs work, but SDL_image and _ttf dont get recognized.

I have all the SDL-files i need installed on Ubuntu 9.04. Jaunty

~$ dpkg -l | grep libsdl
ii  libsdl-image1.2                            1.2.6-3                                image loading library for Simple DirectMedia
ii  libsdl-image1.2-dev                        1.2.6-3                                development files for SDL 1.2 image loading
ii  libsdl-mixer1.2                            1.2.8-5                                mixer library for Simple DirectMedia Layer 1
ii  libsdl-mixer1.2-dev                        1.2.8-5                                development files for SDL1.2 mixer library
ii  libsdl-sound1.2                            1.0.3-3                                Decoder of several sound file formats for SD
ii  libsdl-sound1.2-dev                        1.0.3-3                                Development files for SDL_sound
ii  libsdl-ttf2.0-0                            2.0.9-1                                ttf library for Simple DirectMedia Layer wit
ii  libsdl-ttf2.0-dev                          2.0.9-1                                development files for SDL ttf library (versi
ii  libsdl1.2-dev                              1.2.13-4ubuntu3                        Simple DirectMedia Layer development files
ii  libsdl1.2debian                            1.2.13-4ubuntu3                        Simple DirectMedia Layer
ii  libsdl1.2debian-alsa                       1.2.13-4ubuntu3                        Simple DirectMedia Layer (with X11 and ALSA

I open a new sdl-template-codeblocks project and go project->properties->libraries and include sdl (it only finds sdl and NOT SDL_image or SDL_ttf).

Then I include the following to my main.cpp:

#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"

I build it .........

ERROR:

Compiling: main.cpp
Linking console executable: bin/Debug/klaar
obj/Debug/main.o: In function `clean_up()':
/home/peter/Documents/lesson07/klaar/main.cpp:135: undefined reference to `TTF_CloseFont'
/home/peter/Documents/lesson07/klaar/main.cpp:138: undefined reference to `TTF_Quit'
obj/Debug/main.o: In function `init()':
/home/peter/Documents/lesson07/klaar/main.cpp:92: undefined reference to `TTF_Init'
obj/Debug/main.o: In function `load_image(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/peter/Documents/lesson07/klaar/main.cpp:38: undefined reference to `IMG_Load'
obj/Debug/main.o: In function `load_files()':
/home/peter/Documents/lesson07/klaar/main.cpp:110: undefined reference to `TTF_OpenFont'
obj/Debug/main.o: In function `main':
/home/peter/Documents/lesson07/klaar/main.cpp:162: undefined reference to `TTF_RenderText_Solid'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 0 warnings

Plz help. Thank you in advance for your time.

PS. I know theres a way to permanently configure c::b to thoses sdl-libs via setting->compiler&debugger->?. But I dont know what to link or where.


oBFusCATed

Quote from: peterjoziasse on September 06, 2010, 05:28:46 AM
I open a new sdl-template-codeblocks project and go project->properties->libraries and include sdl (it only finds sdl and NOT SDL_image or SDL_ttf).
What does this mean?
You've to use `sdl-config --cflags` and `sdl-config --libs`

Have you read this: http://www.libsdl.org/projects/SDL_image/docs/SDL_image.html (2.2 Compiling)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

peterjoziasse

when i use the command line i get:

~$ sdl-config --cflags --libs
-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
-L/usr/lib -lSDL

I dont know what to do with this. I dont want to use the command line. I want to use code::blocks, write my program and hit "Build and Run". Is there a way to setup codeblocks to automatically use SDL_image and SDL_ttf?

kencamargo

Quote from: peterjoziasse on September 06, 2010, 06:34:37 PM
when i use the command line i get:

~$ sdl-config --cflags --libs
-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
-L/usr/lib -lSDL

I dont know what to do with this. I dont want to use the command line. I want to use code::blocks, write my program and hit "Build and Run". Is there a way to setup codeblocks to automatically use SDL_image and SDL_ttf?

You are using the command line whether you want or not.

Anyway, menu Project|Build Options

Look for Compiler settings, tab Other options, add `sdl-config --cflags` (exactly like that)
Then look for Linker settings, Other link options, `sdl-config --libs` (again, exactly like that)

Should do the trick. Usually helps when you know what you are doing.
And, finally, 8.02 is a very outdated version of C::B.

HTH,
Ken


peterjoziasse

That did work. Thank you for the quick reply. I'm trying to learn c++, sdl and hopefully opengl. I know my way around C, java and some prolog. Now that everything is set up correctly, i can try the code as i learn (helps to code alongside just reading :)).

I'll alsp look into the new versions of c::b and sdl.

When my C::B-fu gets better, hopefully I can help others on this forum. For now I'll just browse and not ask newbie questions.

Thanks again!! :D