"winapifamily.h: No such file or directory" when compiling SDL in Code :: Blocks

I follow along with the LazyFoo SDL2.0 tutorials using Code :: Blocks 13.12. I had no problems connecting and starting SDL2 in VS2010, but with a modified IDE and encountering this error:

winapifamily.h: No such file or directory

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

Buildlog: (an error occurs in the file: .. \ include \ SDL2 \ SDL_platform.h)

=== Build: Debug in SDL2_Setup (compiler: GNU GCC compiler) ===

fatal error: winapifamily.h: no such file or directory

=== Build failed: 1 error, 0 warnings (0 minutes, 0 seconds) ===

This is my first question asking a question here. I did Google for an answer and looked for existing questions / answers here, but couldn't solve the problem. Here is my code.

My code is:

// 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; } 
+47
c ++ codeblocks sdl sdl -2
Mar 17 '14 at 2:36
source share
3 answers

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




This is a bug in SDL 2.0.3. Fixed a fix for the next SDL release. In the meantime, here is a link to a fixed copy of SDL_platform.h:

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

If you drop the file in SDL 2.0.3, include the \ SDL2 \ directory, overwriting the original, your applications should compile ok.

+63
Mar 24 '14 at 2:31
source share

Quick fix. Comment lines 121 through 132 inclusive in SDL_platform.h If an error occurs, the file is uploaded to C :: B. Save it and remove it!

+9
Jun 03 '14 at 15:34
source share

I had this problem. Go to

 C:\Program Files (x86)\Windows Kits\8.0\Include\shared 

and find winapifamily.h , then copy it to

 ..\Mingw\Include\ folder 



Edit: I think I have files with window sets due to visual studio 2012 or later, sorry. I am glad that you were able to solve your problem.

Yeap, the problem is in this header (lines 117 through 134 in SDL_plataform.h SDL 2.0.3):

 #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__) */ 
+1
Mar 17 '14 at 4:11
source share



All Articles