sdl 链接问题 ubuntu
sdl linking prolem ubuntu
我有 Ubuntu 14 个 LT 我正在尝试使用 SDL 编译一个简单的代码 library.but 我得到了答案:
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;
}``
`
正确的函数名称是 SDL_GetError(),而不是 SDL_Get_Error()。参见 http://wiki.libsdl.org/SDL_GetError
我有 Ubuntu 14 个 LT 我正在尝试使用 SDL 编译一个简单的代码 library.but 我得到了答案:
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;
}``
`
正确的函数名称是 SDL_GetError(),而不是 SDL_Get_Error()。参见 http://wiki.libsdl.org/SDL_GetError