Rename external/lib/z.lib to something else. I ran into the same problem with Cygwin: for some reason, this zlib is included and is part of the library path. But it doesn’t work with Cygwin. Renaming it allows gcc in Cygwin to find and link against the correct zlib.
Sorry if this is a duplicate; I’m not seeing my posts show up.