sdl_net The application was unable to start correctly (0xc000007b)

1

I'm trying to compile and run the following code:

#include <iostream>
#include <SDL.h>
#include <SDL_net.h>
#include <cstring>


using namespace std;

int main(int argc, char **argv)
{
    printf("result of SDL_Init is: %i\n",SDL_Init(SDL_INIT_EVERYTHING));
    printf("result of SDLNet_Init is: %i\n",SDLNet_Init());
}

The code compiles fine, but when I run it I get an error:

The application was unable to start correctly (0xc000007b). Click OK to close the application

I've successfully compiled and run SDL code before, but this is my first time trying out SDL_Net.

I'm using Code::Blocks on Windows with MinGW GCC compiler, I'm using the x86_64-w64-mingw32 libraries for SDL, and these are my linker settings (some of which are not immediately necessary, I know):

-lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lpthread -lSDL2_net

Does anyone know what's going on here?

//ETA:

How can I resolve this issue without switching all my stuff over to 32-bit?

Thanks,

c++
sdl-2
sdl-net
asked on Stack Overflow May 18, 2018 by boxcartenant • edited Aug 17, 2018 by boxcartenant

1 Answer

1

I solved the issue by the following:

  1. Installed mingw-w64 instead of mingw32 and set that as my compiler. I had to change most of the toolchain executables so that they pointed to files with "x86_64-w64-mingw32-" in the name (for example, "gcc.exe" was changed to "x86_64-w64-mingw32-gcc.exe"). the Resource Compiler and Make program names were unchanged.

  2. Using the binaries in the x86_x64-mingw32 folder of the SDL_Net development library did not work. I had to replace them with the SDL2_net-2.0.1-win32-x64 runtime binaries that you can download directly on the SDL_Net homepage.

//Note: Maybe the "i686-w64-mingw32" development library binaries would have worked... I didn't test it. I always get confused when "64" is prefaced by "86" and "686", and in the case of these dev libraries, the other option is "x86_64-w64-mingw32".... so which one is really x64, and which one is x32? Not sure.

  1. After I made that change, I stopped getting the titular error in my original post. Instead, now when I try to run the compiled program, I would get errors about missing DLLs. Further, these errors only happened when I ran the program via the executable in "debug"; the errors didn't happen when I ran the program by pressing the "play" button in Code::Blocks. After some hunting, I solved this problem by changing my linker options to the following:

-lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_net -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic

//Note: I don't actually fully understand what "-Wl,-Bstatic" and "-Wl,-Bdynamic" do. I wish someone would explain that to me.

I hope this helps somebody!

answered on Stack Overflow May 18, 2018 by boxcartenant

User contributions licensed under CC BY-SA 3.0