Search code examples
c++cmakesdl-2mingw-w64

CMake and MinGW w64 and windows system libraries


I start to learn CMake. I want to build my application with SDL2 library using MinGW w64. I generate Makefiles and use mingw32-make for building my app. But my app doesn't execute without any messages (my OS is Windows 10). First about I thought that my app doesn't see it dependecies. I try to use DependencyWalker and figure out next. My app doesn't see libriries like

API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL API-MS-WIN-CORE-APPCOMPAT-L1-1-0.DLL API-MS-WIN-CORE-APPCOMPAT-L1-1-1.DLL API-MS-WIN-CORE-APPINIT-L1-1-0.DLL

and many other API-MS-WIN libraries. As I can see this libraries lie in C:\Windows\System32 and in C:\Windows\SysWOW64. When I build my app I link next libraries -lmingw32 -lSDL2main -lSDL -mwindows and it links without any errors and DependencyWalker doesn't say something bad about this. Why my built app didn't see windows system libraries? My PATH environment has System32 directory but hasn't SysWOW64. Maybe is problem in this?

UPDATE

I try add to PATH environment SysWOW64 and it doesn't help. Add DependecyWalker screenshots

one

two

three

UPDATE 2

collapsed


Solution

  • Oh, no! I did a big mistake. My problem is not windows dll. I follow to this guide. I didn't write part of code where windows are creating. My code was

    //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_Error: %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 );
        }
    }
    

    Be careful when you write code from examples:) I fixed this by adding part that I missed. Now my program works fine.