c++windowsdll

C++ Program will not run due to Windows DLL issue


This code will run on your machine, but not on mine:

#include <iostream>
#include <vector>

using namespace std;

int main(){

    vector<int> vv;

    vv.push_back(1); //<--- without this, everything works

    cout << "X\n";

    return 0;
}

The reason, is that it appears my windows machine is missing a (or has a conflicting) specific DLL related to Vectors which is causing my other projects to crash without a report if I use vectors.

However, what's even more entertaining is:

  1. If I comment the push back line, it executes normally without a crash.
  2. Other programs work completely fine as long as they avoid vector, as in using list or an array.

GDB Reports "During startup program exited with code 0xc0000139." Which means it couldn't find the dll it wants. Looking through the dependencies of my executable with Dependency Walker is rather inconclusive, I can't tell what is wrongly missing and what is normally missing among the dlls.

It could also be that there is a second dll that is conflicting with it (like I downloaded two different compilers). Investigating with Process Monitor informs me that instead of using the MinGw64 files located in the MSYS2 folder, the process uses the dlls inside of my ProgramFiles/Git/mingw64/bin location.

So it could be an issue? But Process Monitor doesn't tell me why or what is causing the process to exit unsuccessfully...

How would I get Windows to use the dlls in MSYS2 instead of the Git location? The solution that the post I linked above says is to remove the "erroneous dlls." But I can't just remove dlls that git uses?

Also, how am I guaranteed that switching to the dlls within MSYS2 is going to fix my problem? I just want to use vectors lol, how hard does this have to be?

Other solutions include leaving this spyware infested OS and enter the world of Linux, but that's a huge change.


Solution

  • I solved this issue by first updating mingw64 using MSYS2, and then copying the conflicting dlls to git/mingw64. This worked for a while, but is a manual annoyance.

    The actual issue was that my "Git for Windows" was out of date. Since it's been updated, and auto-updates have been enabled, I haven't had to copy any dlls anywhere.