LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compiled error (https://www.linuxquestions.org/questions/programming-9/compiled-error-343375/)

kira 07-15-2005 04:09 AM

compiled error
 
error occured while compiling, i got the wrong messages like below:

/tmp/cc4/HK9Z5.o (text+0x16): in function 'main'
:undefined reference to 'SDL_Init'

the command for compilation is : gcc -o sdl sdl.c -W -I /usr/include/SDL
the score code is:

#include <stdlib.h>
#include "SDL.h"

main(int argc, char *argv[])
{
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "can't initilize SDL: %s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
}

thanks in advance.

sind 07-15-2005 06:22 AM

I haven't used SDL before, but I think using this might make it work:

Code:

$ gcc -o sdl sdl.c -W -I /usr/include/SDL -lSDL
Have a look at the output of:

Code:

$ sdl-config --libs
if it still doesn't work and if that command is available.

~sind

rockytriton 07-15-2005 10:33 AM

You need to link to the SDL library, check the docs for SDL, they should have sample make files.


All times are GMT -5. The time now is 12:24 PM.