【发布时间】:2014-04-22 03:57:29
【问题描述】:
我正在关注 LazyFoo 的 SDL2.0 教程,使用 Code::Blocks 13.12。我在 VS2010 中链接和运行 SDL2 没有任何问题,但更改了 IDE 并遇到此错误:
winapifamily.h: 没有这样的文件或目录
我认为一切都正确链接。我已将程序指向我的 SDL2 包含和 lib 目录。
Buildlog:(文件中出现错误:..\include\SDL2\SDL_platform.h)
=== 构建:在 SDL2_Setup 中调试(编译器:GNU GCC 编译器)===
致命错误:winapifamily.h:没有这样的文件或目录
=== 构建失败:1 个错误,0 个警告(0 分钟,0 秒)===
这是我第一次在这里提问。我在谷歌上搜索了答案并在这里搜索了现有的问题/答案,但无法解决问题。这也是我的代码。
我的代码:
// 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;
}
【问题讨论】:
-
我认为 VS 10 没有这个头文件。这是一个新的标题。检查您的项目是否有或缺少一些关于操作系统类型的宏。
标签: c++ sdl codeblocks sdl-2