[SDL] Linux: problem linking with SDL

Terry Hancock hancock at earthlink.net
Tue Mar 20 11:22:21 PST 2001


Jakob Frandsen wrote:
> I have a weird problem...
> I installed SDL 1.1.8 and wrote the following program:

Same version I'm using.

I have the following includes -- you shouldn't need SDL_image
unless you're using the SDL Image library. I'm not sure why
I have the SDL Endian include.

#include <SDL.h>
#include <SDL_endian.h>
#include <SDL_image.h>

> ---[CUT]---
> [... code snips omitted ...]
> ---[CUT]---

The Makefile looks right to me, comparing with what I'm
using.

> Typing make produces this:
> 
> g++ -g -I/usr/include/SDL -c main.cpp
> g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
> -o test main.o
> main.o: In function `main':
> /home/jakob/tmp2/main.cpp:9: undefined reference to `SDL_Init'
> /home/jakob/tmp2/main.cpp:11: undefined reference to `SDL_GetError'
> /home/jakob/tmp2/main.cpp:14: undefined reference to `SDL_Quit'
> collect2: ld returned 1 exit status
> make: *** [test] Error 1
> 
> Why is that?? I have tried everything, changing the order of the
> $(LIBFLAGS) and adding "-L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi
> -lSM -lICE -ldl -lpthread"..

So far, the only thing I can think of is maybe the libraries aren't
actually where they belong.  Mine are in /usr/lib and include:

libSDL-1.1.so.0
libSDL-1.1.so.0.5.3
libSDL.a
libSDL.la
libSDL.so
libSDLmain.a

(some of which are probably from earlier versions, but you should
have something like this there).

Just in case, here's the text from my makefile, which does work:

#
INCLUDE  = -I/usr/include/ -I/usr/include/SDL
LIBS     = -L/usr/lib/ -lSDL -lSDL_image -lSGE -lpthread

automanga: automanga2.cpp
	g++ $(INCLUDE) $(LIBS)  automanga2.cpp -o automanga

blits: blits.c seesdl.c seesdl.h
	g++ $(INCLUDE) $(LIBS)  blits.c seesdl.c -o blits


-- 
Terry Hancock
hancock at earthlink.net



More information about the SDL mailing list