Hello list,
I’m new to SDL and I’m trying to compile a simple test program found at
http://www.libsdl.org/intro/toc.html. The code is the following.
#include <stdio.h>
#include “/usr/include/SDL/SDL.h”
int main()
{
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
}
Is it necessary to include something else to compile this program?
tairone at cefala06:~/sdlprojects$ gcc sdltest.c -o sdltest.out
Because I’m receiving the following error message.
sdltest.c: In function ‘main’:
sdltest.c:9: warning: incompatible implicit declaration of built-in function
’exit’
/tmp/cckr9bEj.o: In function main': sdltest.c:(.text+0x22): undefined reference to
SDL_Init’
sdltest.c:(.text+0x2e): undefined reference to SDL_GetError' sdltest.c:(.text+0x58): undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
tairone at cefala06:~/sdlprojects$ ls
sdltest.c
(arg: 21)
I don’t what can I do to solve this problem. So any help is welcome.
Thanks,
Tairone Nunes Magalhaes
Hello list,
I’m new to SDL and I’m trying to compile a simple test program found at
http://www.libsdl.org/intro/toc.html. The code is the following.
#include <stdio.h>
#include “/usr/include/SDL/SDL.h”
int main()
{
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, “Unable to init SDL: %s\n”,
SDL_GetError()); exit(1);
}
atexit(SDL_Quit);
}
Is it necessary to include something else to compile this program?
You need to add sdl-config --cflags --libs
to the gcc command line.
Regards, Joonas.On Monday 20 February 2006 20:02, Tairone N. Magalhaes wrote:
tairone at cefala06:~/sdlprojects$ gcc sdltest.c -o sdltest.out
Because I’m receiving the following error message.
sdltest.c: In function ‘main’:
sdltest.c:9: warning: incompatible implicit declaration of built-in
function ‘exit’
/tmp/cckr9bEj.o: In function main': sdltest.c:(.text+0x22): undefined reference to
SDL_Init’
sdltest.c:(.text+0x2e): undefined reference to SDL_GetError' sdltest.c:(.text+0x58): undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
tairone at cefala06:~/sdlprojects$ ls
sdltest.c
(arg: 21)
I don’t what can I do to solve this problem. So any help is welcome.
Thanks,
Tairone Nunes Magalhaes
–
Joonas “dolphin” Lahtinen <@Joonas_Lahtinen>
Hello !
#include “/usr/include/SDL/SDL.h”
That should be “#include SDL.h”
int main() {
That needs to be :
int main (int argc, char *argv []) {
CU
It also needs an #include <stdlib.h> for the call to atexit().On 2/20/06, Torsten Giebl wrote:
Hello !
That should be “#include SDL.h”
Sorry, my fault.
This should be :
#include “SDL.h”
CU
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
–
Cheers,
Josh
PGP: http://revvy.box43.net/Josh_Matthews.asc
Tairone N. Magalhaes wrote:
#include <stdio.h>
#include “/usr/include/SDL/SDL.h”
int main()
{
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
}
Is it necessary to include something else to compile this program?
tairone at cefala06:~/sdlprojects$ gcc sdltest.c -o sdltest.out
Yes, you need to link with the SDL library:
$ gcc -o sdstest sdltest.c -lSDL
August