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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With