LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Strange /tmp error messages when compiling (https://www.linuxquestions.org/questions/programming-9/strange-tmp-error-messages-when-compiling-208614/)

LavaDevil94 07-23-2004 02:32 AM

Strange /tmp error messages when compiling
 
I'm trying to compile this program to start off my entry into SDL:
Code:

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

int main()
{
  if ( SDL_Init(SDL_INIT_VIDEO) <0 ) {
    printf("Unable to init SDL: %s\n", SDL_GetError());
    return 1;
  }
  atexit(SDL_Quit);
}

But when I do, I get error messages like this:
Code:

/tmp/ccMdsGbg.o(xtest+0x16): In function `main':
: undefined reference to `SDL_Init'
/tmp/ccMdsGbg.o(xtest+0x16): In function `main':
: undefined reference to `SDL_GetError'
/tmp/ccMdsGbg.o(xtest+0x16): In function `main':
: undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status

I can't gather any useful knowledge from these messages, but maybe you guys can?

Kumar 07-23-2004 02:46 AM

Try this -
cc sdl.c -lSDL -lpthread

LavaDevil94 07-23-2004 02:50 AM

It works :D! Thanks Kumar, I've had this error for awhile, and now it's all gone!
Thanks again!

Kumar 07-23-2004 02:52 AM

well....actually you were missing the required libraries.

Hko 07-23-2004 05:26 AM

Quote:

Originally posted by Kumar
Try this -
cc sdl.c -lSDL -lpthread

Better yet:

Change this line:
Code:

#include </usr/include/SDL/SDL.h>
to:
Code:

#include "SDL.h"
And then compile with:
Code:

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


All times are GMT -5. The time now is 02:53 PM.