Hey, I’m relatively new to SDL and the concept of linkers. I’m getting a few
link errors while running through the examples in the programming linux games
book. For example:
bash-2.05b$ sdlcc ./alpha-sdl
/tmp/cc6RCJ1O.o(.text+0xa3): In function main': : undefined reference to
IMG_Load’
/tmp/cc6RCJ1O.o(.text+0xd0): In function main': : undefined reference to
IMG_Load’
/tmp/cc6RCJ1O.o(.text+0xfd): In function main': : undefined reference to
IMG_Load’
collect2: ld returned 1 exit status
Here are my includes:
/* Example of alpha blending with SDL. */
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <stdio.h>
#include <stdlib.h>
and one line where I’m using IMG_Load:
image_with_alpha = IMG_Load(“with-alpha.png”);
And here is the very quick and dirty script I’m using to gcc stuff:
gcc $1.c $2 $3 $4 $5 $6 $7 $8 $9 -o $1 sdl-config --cflags --libs
Yes, I know this line is hideous, it was after midnight, and I just
didn’t want to type a lot when I created it.
I seem to be able to get most things that only rely on SDL/SDL.h to work,
but SDL_image.h seems to hate me…
I can track down most compiler error messages, but I get a little symied when
it comes to linker errors. As far as I can tell from the SDL docs, I should
be able to make that call. Any hints on where I should be looking to correct
this would be appreciated.
Thanks,
Austin