再次求助
sdl吧
全部回复
仅看楼主
level 3
undefined reference to `IMG_Load'|
按照教程中配置SDL扩展库的时候出现了问题
明明按照教程将SDL_image放到include文件夹里了,
lib文件也放到lib文件夹里面了
x64里的dll文件也放到SysWOW文件夹里了
发生这个错误的可能原因是什么呢
附上代码
//头文件
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <string>
//窗口属性
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;
//将要使用的表面
SDL_Surface *message = NULL;
SDL_Surface *background = NULL;
SDL_Surface *screen = NULL;
SDL_Surface *load_image( std::string filename )
{
//临时的空间,用于存储刚刚加载好的图像
SDL_Surface* loadedImage = NULL;
//优化后的图像,实际使用的是这个图像
SDL_Surface* optimizedImage = NULL;
//加载图像
loadedImage = IMG_Load( filename.c_str() );
//如果加载图片没有出错
if( loadedImage != NULL )
{
//创建一个优化了的图像
optimizedImage = SDL_DisplayFormat( loadedImage );
//释放临时的图像
SDL_FreeSurface( loadedImage );
}
//返回优化后的表面
return optimizedImage;
}
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
//新建一个临时的矩形来保存偏移量
SDL_Rect offset;
//将传入的偏移量保存到矩形中
offset.x = x;
offset.y = y;
//执行表面的Blit
SDL_BlitSurface( source, NULL, destination, &offset );
}
int main( int argc, char* args[] )
{
//初始化SDL的所有子系统
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return 1;
}
//设置窗口
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
//如果设置窗口时出现错误
if( screen == NULL )
{
return 1;
}
//设置窗口标题
SDL_WM_SetCaption( "Hello World", NULL );
//加载图片
message = load_image( "hello.bmp" );
background = load_image( "background.bmp" );
//将背景图片background应用到screen上
apply_surface( 0, 0, background, screen );
apply_surface( 320, 0, background, screen );
apply_surface( 0, 240, background, screen );
apply_surface( 320, 240, background, screen );
//将message表面应用到窗口中
apply_surface( 105, 128, message, screen );
//更新窗口
if( SDL_Flip( screen ) == -1 )
{
return 1;
}
//等待2秒
SDL_Delay( 3000 );
//释放表面
SDL_FreeSurface( message );
SDL_FreeSurface( background );
//退出SDL
SDL_Quit();
//main函数返回
return 0;
}
2018年04月15日 12点04分 1
level 11
检查是否加载了SDL2_image
2018年05月30日 17点05分 3
1