Try renaming 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.
BTW, the only reason I know this is that I happened to be sitting next to Sergey at RosettaCon? when this error came up