我正在跟随LazyFoo的SDL2.0教程,使用Code::Blocks 13.12。在VS2010上链接和运行SDL2没有问题,但现在我换了IDE并遇到了这个错误:
winapifamily.h: 没有那个文件或目录
我认为一切都已经正确链接了。我已将程序指向我的SDL2包含和库目录。
构建日志:(错误出现在文件:..\include\SDL2\SDL_platform.h)
=== 构建:SDL2_Setup的Debug(编译器:GNU GCC Compiler) ===
致命错误:winapifamily.h: 没有那个文件或目录
=== 构建失败:1个错误,0个警告(0分钟,0秒)===
这是我第一次在这里提问。我已经在Google上寻找答案并搜索了现有的问题/答案,但无法解决这个问题。下面是我的代码。
我的代码:
// Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
// Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] )
{
// The window we'll be rendering to
SDL_Window* window = NULL;
// The surface contained by the window
SDL_Surface* screenSurface = NULL;
// Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO) < 0 )
{
printf( "SDL could not initialize! SDL_GetError: %s\n", SDL_GetError() );
}
else
{
// Create window
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
printf( "Window could not be created! SDL_GetError: %s\n", SDL_GetError() );
}
else
{
// Get window surface
screenSurface = SDL_GetWindowSurface( window );
// Fill the surface white
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF));
// Update the surface
SDL_UpdateWindowSurface( window );
// Wait two seconds
SDL_Delay( 2000 );
}
}
// Destroy window
SDL_DestroyWindow( window );
// Quit SDL subsystems
SDL_Quit();
return 0;
}