Compilling Errors

Hey,
I am newbie to SDL so i was wondering if somebody
could help me figure what this error message means. I
tried compile the following code:

/* Example of initializing SDL. */

#include </usr/include/SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
SDL_Surface *screen;

/* Initialize SDL's video system and check for

errors */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf(“Unable to initialize SDL: %s\n”,
SDL_GetError());
return 1;
}

/* Make sure SDL_Quit gets called when the program

exits! */
atexit(SDL_Quit);

/* Attempt to set a 640x480 hicolor video mode */
screen = SDL_SetVideoMode(640, 480, 16,

SDL_FULLSCREEN);
if (screen == NULL) {
printf(“Unable to set video mode: %s\n”,
SDL_GetError());
return 1;
}

/* If we got this far, everything worked */
printf("Success!\n");

return 0;

}****************************************************
the folowinf is the error message that i received:

/tmp/ccBjZjTj.o: In function main': /tmp/ccBjZjTj.o(.text+0x16): undefined reference to SDL_Init’
/tmp/ccBjZjTj.o(.text+0x28): undefined reference to
SDL_GetError' /tmp/ccBjZjTj.o(.text+0x4a): undefined reference to SDL_Quit’
/tmp/ccBjZjTj.o(.text+0x68): undefined reference to
SDL_SetVideoMode' /tmp/ccBjZjTj.o(.text+0x7f): undefined reference to SDL_GetError’
collect2: ld returned 1 exit status


Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more

Hi there,


the folowinf is the error message that i received:

/tmp/ccBjZjTj.o: In function main': /tmp/ccBjZjTj.o(.text+0x16): undefined reference toSDL_Init’
/tmp/ccBjZjTj.o(.text+0x28): undefined reference to
SDL_GetError' /tmp/ccBjZjTj.o(.text+0x4a): undefined reference toSDL_Quit’
/tmp/ccBjZjTj.o(.text+0x68): undefined reference to
SDL_SetVideoMode' /tmp/ccBjZjTj.o(.text+0x7f): undefined reference toSDL_GetError’
collect2: ld returned 1 exit status

this looks like you forgot to put -LSDL to your compiler/linker
option. if the command “sdl-config” works … you just need to compile
your program with

gcc -o program program.c `sdl-config --cflags --libs`

this should work…

oky bye bye
Steffen–

Steffen Pohle (@Steffen_Pohle)
http://stpohle.bei.t-online.de
JabberID: stpohle at amessage.de
ICQ: 370965 Yahoo: stpohle
MSN: stpohle at hotmail.com

Hey Steffen,
thanks for the advice it sure did work.
— Steffen Pohle wrote:> Hi there,


the folowinf is the error message that i received:

/tmp/ccBjZjTj.o: In function main': /tmp/ccBjZjTj.o(.text+0x16): undefined reference toSDL_Init’
/tmp/ccBjZjTj.o(.text+0x28): undefined reference
to
SDL_GetError' /tmp/ccBjZjTj.o(.text+0x4a): undefined reference toSDL_Quit’
/tmp/ccBjZjTj.o(.text+0x68): undefined reference
to
SDL_SetVideoMode' /tmp/ccBjZjTj.o(.text+0x7f): undefined reference toSDL_GetError’
collect2: ld returned 1 exit status

this looks like you forgot to put -LSDL to your
compiler/linker
option. if the command “sdl-config” works … you
just need to compile
your program with

gcc -o program program.c sdl-config --cflags --libs

this should work…

oky bye bye
Steffen

Steffen Pohle (stpohle at gmx.net)
http://stpohle.bei.t-online.de
JabberID: stpohle at amessage.de
ICQ: 370965 Yahoo: stpohle
MSN: stpohle at hotmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more