I had this same problem, but fixed it like this:
-
I ran the
MinGW Installation Manager(e.g.C:\MinGW\libexec\mingw-get\guimain.exe). -
I navigated to
All Packages -> MinGW -> MinGW Libraries. -
I checked the boxes next to
mingw32-libz(dev&dll).
-
I went to
Installation -> Apply Changes.
Now everything worked properly.