本文介绍了“winapifamily.h:没有这样的文件或目录”当编译SDL在Code :: Blocks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着SDL2.0教程,由LazyFoo,使用Code :: Blocks 13.12。我已经没有麻烦得到SDL2链接和运行在VS2010,但改变IDE和遇到这个错误:

我认为一切都正确链接。我已将程序指向我的SDL2包含和lib目录。



Buildlog:(错误发生在文件中:.. \include\\ \\ SDL2 \SDL_platform.h)

这是我的第一个时间在这里问一个问题。我向Google请求了答案,并在此处搜索了现有的问题/答案,但无法解决问题。这是我的代码。



我的代码

 code> //使用SDL和标准IO 
#include< SDL.h>
#include< stdio.h>

//屏幕维度常量
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main(int argc,char * args [])
{
//我们要渲染到的窗口
SDL_Window * window = NULL;

//窗口包含的表面
SDL_Surface * screenSurface = NULL;

//初始化SDL
if(SDL_Init(SDL_INIT_VIDEO)< 0)
{
printf(SDL无法初始化!SDL_GetError:%s\\\
,SDL_GetError());
}
else
{
//创建窗口
window = SDL_CreateWindow(SDL Tutorial,SDL_WINDOWPOS_UNDEFINED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
if(window == NULL)
{
printf(无法创建窗口!SDL_GetError:%s\\\
,SDL_GetError());
}
else
{
//获取窗口表面
screenSurface = SDL_GetWindowSurface(window);

//填充表面白色
SDL_FillRect(screenSurface,NULL,SDL_MapRGB(screenSurface-> format,0xFF,0xFF,0xFF));

//更新曲面
SDL_UpdateWindowSurface(window);

//等待两秒钟
SDL_Delay(2000);
}
}

//销毁窗口
SDL_DestroyWindow(window);

//退出SDL子系统
SDL_Quit();

return 0;
}


解决方案

strong>:SDL 2.0.4现已失效,包含此错误的修复程序,可从以下网址下载:






这是SDL 2.0中的一个错误。 3。已经为SDL的下一个版本提交了修复。同时,这里有一个指向SDL_platform.h的固定副本的链接:





如果你把文件放到SDL 2.0.3的include\SDL2 \目录,覆盖原来的,你的应用程序应该编译ok。


I am following along with the SDL2.0 tutorials by LazyFoo, using Code::Blocks 13.12. I have had no trouble getting SDL2 linked and running in VS2010 but have changed IDE and come across this error:

I think everything is linked correctly. I have pointed the program to my SDL2 include and lib directories.

Buildlog: (error is occuring in file: ..\include\SDL2\SDL_platform.h)

This is my first time asking a question on here. I did Google for an answer and search the existing questions/answers on here but was unable to solve the issue. Here is my code also.

My Code:

// 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;
}
解决方案

UPDATE: SDL 2.0.4 is now out, includes a fix for this bug, and is available for download at http://libsdl.org/download-2.0.php


This is a bug in SDL 2.0.3. A fix has been committed for SDL's next release. In the meantime, here's a link to the fixed copy of SDL_platform.h:

https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h

If you drop the file into SDL 2.0.3's include\SDL2\ directory, overwriting the original, your app(s) should compile ok.

这篇关于“winapifamily.h:没有这样的文件或目录”当编译SDL在Code :: Blocks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:51