The application was unable to start correctly 0xc00007b for an SDL2 application

-1

I am building an SDL application on my x64 Windows 10 machine using Visual Studio.

I have set up the include/library/additional dependencies following this tutorial.

Everything works fine until I add the SDL_ttf library following the example above as guideline, and paste the SDL2_ttf.dll to the debug folder.

I get this error:

"The application was unable to start correctly (0xc000007b). Click Ok to close the application.*

If I remove SDL2_ttf.dll from the folder, I get (only) this error:

I downloaded the .dll (x64 version) from this link.

My SDL2.dll and SDL2_image.dll (both x64) work correctly as my executable runs when I only use those libraries.

What's the issue here? Why could I be getting this error?

Additional info

  • I checked system32 folder (and the whole Windows parent folder) and I didn't find SDL_ttf.dll there.

  • Also, this is what my debug folder looks like:

This is the simple code example I am running

//Using SDL and standard IO
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <SDL_ttf.h>

//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

SDL_Window* gWindow = nullptr;
SDL_Surface* gScreenSurface = nullptr;

bool init()
{
    //Initialization flag
    bool success = true;
    
    IMG_Init(IMG_INIT_PNG);

    TTF_Init();

    //Initialize SDL
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
        success = false;
    }
    
    else
    {
        //Create window
        gWindow = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
        if (gWindow == NULL)
        {
            printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
            success = false;
        }
        else
        {
            //Initialize PNG loading
            int imgFlags = IMG_INIT_PNG;
            if (!(IMG_Init(imgFlags) & imgFlags))
            {
                printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
                success = false;
            }
            else
            {
                //Get window surface
                gScreenSurface = SDL_GetWindowSurface(gWindow);
            }
        }
    }

    return success;
}

int main(int argc, char* args[])
{
    init();

    //Destroy window
    SDL_DestroyWindow(gWindow);

    //Quit SDL subsystems
    SDL_Quit();

    return 0;
}

EDIT: tidied code

EDIT: I have an idea why I am seeing this issue. I copied some library files to my MinGW folder the other day and I may have overwritten some important dll files that SDL2 uses (behind the scenes). If I get to the bottom of it, I will post. Likewise, I may get a fresh install of MinGW and will post an update if the issue is resolved.

EDIT: I finally have it working. It looks like I have a dll somewhere in my PATH that is not suitable for my x64 application and it wasn't any of the 3 dlls I mentioned above. This is what my working folder looks like.

windows
visual-c++
dll
64-bit
sdl-2
asked on Stack Overflow Sep 24, 2020 by Eon • edited Sep 24, 2020 by Eon

1 Answer

0

After a fresh install of MinGW using MinGW installation manager the program started to give different errors indicating which dll was missing. The SDL runtime library folder contained all these folders. I copied the x64 version of them and the application ran successfully.

answered on Stack Overflow Sep 24, 2020 by Eon

User contributions licensed under CC BY-SA 3.0