Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application compiled in mingw-w64/msys2, "the application was unable to start correctly (0xc00007b"

After compiling an application in the mingw-w64 64-bit Shell, it runs fine inside the shell, but gives an error the application was unable to start correctly (0xc00007b) when run normally, outside the shell.

I moved some of the necessary DLLs from the msys2/mingw-w64 bin directories when it complained about missing them, but now it gives this opaque error. What am I doing wrong?

like image 801
Realz Slaw Avatar asked Dec 16 '15 23:12

Realz Slaw


1 Answers

Error 0xc00007b basically means "invalid image format" which usually happens when mixing 64-bit and 32-bit DLLs. What is happening, is that you have a 64-bit application, looking for a particular DLL, which is in the global path, but the one in the path is 32-bit. Therefore, the problem is: it does not complain about the missing DLL, it just tries to load it. Since it is a 32-bit application, and your application is a 64-bit application, you get error 0xc00007b.

The solution is to copy all the dependent DLLs over to the application path.

The next problem is you don't know which ones.

What you can do with msys2 shell is: go to the directory and run the command:

ldd application.exe

This will give you a list of DLLs the application depends on. Copy the msys2/mingw-w64 related DLLs to the directory. This will allow the application to find them before looking in the PATH and finding the 32-bit DLLs.

like image 79
Realz Slaw Avatar answered Oct 21 '22 17:10

Realz Slaw