Compiuling proplems

Dear List,

I?ve run in trouble to add SDL support in my own programs. I?ve wrote a
very simple test program and got the following error messages:

gcc -o grw_test grw_main.o
grw_main.o: In function main': grw_main.o(.text+0xc): undefined reference toSDL_Init’
grw_main.o(.text+0x1d): undefined reference to SDL_GetError' grw_main.o(.text+0x45): undefined reference toSDL_Quit’
grw_main.o(.text+0x63): undefined reference to SDL_SetVideoMode' grw_main.o(.text+0x79): undefined reference toSDL_GetError’
grw_main.o(.text+0xa8): undefined reference to SDL_EventState' grw_main.o(.text+0xb8): undefined reference toSDL_WaitEvent’
collect2: ld returned 1 exit status
make: *** [grw_test] Error 1

But compiling with the following command is succesfull:

gcc grw_main.c $(bash sdl-config --libs) $(bash sdl-config --cflags) -o
grw_test

What is wrong with the Makefile?---------------------------------

TARGET = grw_test

OBJECTS = grw_main.o

from the SDL-FAQ

SDL_LDFLAGS := $(bash sdl-config --libs)
SDL_CFLAGS := $(bash sdl-config --cflags)

$(TARGET): $(OBJECTS); gcc -o $(TARGET) $(OBJECTS) $(SDL_LDFLAGS)
$(SDL_CFLAGS)

grw_main.o: grw_main.c; gcc -c grw_main.c


Regards, Sven

$(TARGET): $(OBJECTS); gcc -o $(TARGET) $(OBJECTS) $(SDL_LDFLAGS)
$(SDL_CFLAGS)

Are these really two separate lines?
If so, stick a “” at the end of the top one to cause the 2nd one to
be read as part of that line. :slight_smile:

Or, just remove the EOL character at the end of the first line to make
it all one line.

-bill!

Sven Garbade writes:

[…]
What is wrong with the Makefile?


TARGET = grw_test

OBJECTS = grw_main.o

from the SDL-FAQ

SDL_LDFLAGS := $(bash sdl-config --libs)
SDL_CFLAGS := $(bash sdl-config --cflags)

$(TARGET): $(OBJECTS); gcc -o $(TARGET) $(OBJECTS) $(SDL_LDFLAGS)
$(SDL_CFLAGS)

grw_main.o: grw_main.c; gcc -c grw_main.c

with sdl-config --libs and sdl-config --cflags, it’s seems to
works !–
Luc Mazardo
http://OCamlSdl.sourceforge.net
Gnu Emacs:flame.el Don’t you realise that it’s a wonderful day?