sdl链接prolem ubuntu

时间:2015-06-02 10:15:58

标签: c ubuntu sdl

我有Ubuntu 14 LT我试图使用SDL库编译一个简单的代码。但我得到答案:

game.c: In function ‘main’:
game.c:11:3: warning: format ‘%s’ expects argument of type ‘char'but argument 3 has type ‘int’ [-Wformat=]  
fprintf (stderr, "could not initialize SDL: %s\n",  SDL_Get_Error());
^
/tmp/ccMGHXqV.o: In function `main':
game.c:(.text+0xa): undefined reference to `SDL_Get_Error'
collect2: error: ld returned 1 exit status

是我编写的程序代码:" gcc game.c -o game sdl-config --cflags`sdl-config --libs"

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

/* my firat game program */

int main()
 {

if ((SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTTHREAD)!=0)
fprintf (stderr, "could not initialize SDL: %s\n",  SDL_Get_Error());
printf ("SDL INIZIALIZED\n");
SDL_Surface* screen;

screen = SDL_SetVideoMode(640, 480, 0,  SDL_ANYFORMAT|     SDL_FULLSCREEN);
SDL_WM_SetCaption("MyFirstGame", NULL);

atexit (SDL_Quit);
return 0;
  }``

`

1 个答案:

答案 0 :(得分:0)

正确的函数名称是SDL_GetError(),而不是SDL_Get_Error()。见http://wiki.libsdl.org/SDL_GetError