在代码中编译 SDL 时"winapifamily.h: No such file or directory":块
"winapifamily.h: No such file or directory" when compiling SDL in Code::Blocks
我跟随LazyFoo的SDL2.0教程,使用Code::Blocks 13.12。我在VS2010中链接和运行SDL2没有问题,但改变了IDE并遇到了这个错误:
winapiffamily .h:没有这样的文件或目录
我认为每件事都是正确的。我已经将程序指向我的SDL2包括和lib目录。
Buildlog:(错误发生在文件:..includeSDL2SDL_platform.h)
=== Build: Debug in SDL2_Setup (compiler: GNU GCC compiler) ===
winapiffamily .h: No such file or directory= = =构建失败:1错误(s), 0警告(s)(0分钟(s), 0秒(s)) = = =
这是我第一次在这里提问。我做了谷歌的答案和搜索现有的问题/答案在这里,但无法解决的问题。这是我的代码。
我的代码:// 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: %sn", 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: %sn", 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现已发布,包括对此错误的修复,并可在http://libsdl.org/download-2.0.php
下载。这是SDL 2.0.3中的一个错误。已经为SDL的下一个版本提交了一个修复。同时,这里有一个指向SDL_platform.h:
的固定副本的链接https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h如果你把文件放入SDL 2.0.3的includeSDL2目录,覆盖原来的,你的应用程序应该可以正常编译。
快速修复。注释掉SDL_platform.h中的第121至132行错误发生时,文件被加载到C::B。省省吧,继续建造吧!
我遇到过这个问题。转到
C:Program Files (x86)Windows Kits8.0Includeshared
找到winapifamily.h
,然后复制到你的
..MingwInclude folder
编辑:我想我有windows工具包文件,因为visual studio 2012或更高版本,对不起。我很高兴你能解决你的问题。
是的,问题在标题中(sdl_platform .h version SDL 2.0.3中的第117至134行):
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
/* Try to find out if we're compiling for WinRT or non-WinRT */
/* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */
#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */
#include <winapifamily.h>
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#undef __WINDOWS__
#define __WINDOWS__ 1
/* See if we're compiling for WinRT: */
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#undef __WINRT__
#define __WINRT__ 1
#endif
#else
#undef __WINDOWS__
#define __WINDOWS__ 1
#endif /* _MSC_VER < 1700 */
#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
- Android NDK clang 编译器错误在 Windows 上显示'No such file or directory'
- 已解决 - C++ 的崇高文本中的"fatal error: opencv: no such file or directory"
- "No such file or directory" C++标头问题
- 我在 #include < bits/stdc++h.> 放置时出错"No such file or directory"
- 叮叮当当。target_include_directories "No such file or directory"
- 从生成文件编译错误:"Unable to open output file" ..."No such file or directory"
- C++编译期间出现"No such file or directory"错误
- 尝试编译 TensorFlow 时出错"/system/bin/linker: No such file or directory"
- 代码块中的哈希库++库"No such file or directory"错误
- 成功使用CMakeLists制作后如何修复"open: No such file or directory"错误(该文件实际上存在)
- QMetaObject::invokeMethod: no such method QTextCursor::MoveO
- 如何在安装了 WSL 的 Visual Studio Code 中修复"g++: error: helloworld.cpp: No such file or directory"?
- 尝试使用生成文件编译程序时"fatal error: boost/regex.hpp: No such file or directory" C++
- SDL 测试程序 - "No such file or directory"
- GDB 列表错误"No such file or directory"
- 我的文件可以编译,但当我尝试运行它时"no such file or directory"
- 无法使用 Qt: "No such file or directory" 打开包含文件
- 如何修复"fatal error: boost/asio.hpp: no such file or directory"?
- ": No such file or directory"执行外壳文件
- QT c++ "Windows.h no such a file or dictionary in main.ccp"