|
这是我的测试程序:
/*
* ball.c
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<errno.h>
#include<sys/types.h>
#include"SDL/SDL.h"
#include"SDL/SDL_image.h"
int err_exit(const char* str);
int main(int argc,char* argv[]){
SDL_Surface* screen;
SDL_Surface* pic;
SDL_Rect src,dest;
if(SDL_Init(SDL_INIT_VIDEO)==-1) //initializes the SDL
err_exit(SDL_GetError());
atexit(SDL_Quit);
screen=SDL_SetVideoMode(800,600,24,0);
if(screen==NULL)
err_exit(SDL_GetError());
pic=IMG_Load("image/pic.jpg");
if(pic==NULL)
err_exit(SDL_GetError());
dest.x=0;
dest.y=0;
dest.w=pic->w;
dest.h=pic->h;
SDL_BlitSurface(pic,NULL,screen,&dest);
SDL_UpdateRects(screen,1,&dest);
SDL_UpdateRect(screen,0,0,0,0);
SDL_FreeSurface(pic);
SDL_Delay(5000);
return 0;
}
int err_exit(const char* str){
fprintf(stderr,"%s",str);
if(errno!=0)
fprintf(stderr,":%d",errno);
exit(1);
}
用 gcc *.c `sdl-config --cflags --libs` -ISDL_image 编译后
出现如下错误:
/tmp/ccqeIWnS.o(.text+0x88): In function `main':
: undefined reference to `IMG_Load'
collect2: ld returned 1 exit status
这是怎么回事啊?
是不是编译命令的参数不对啊!
谢谢指教! |
|