diff -Naur Python-3.7.0-orig/Lib/distutils/command/build_ext.py Python-3.7.0/Lib/distutils/command/build_ext.py --- Python-3.7.0-orig/Lib/distutils/command/build_ext.py 2018-07-12 10:21:57.205216600 +0300 +++ Python-3.7.0/Lib/distutils/command/build_ext.py 2018-07-12 10:22:34.130481400 +0300 @@ -217,7 +217,7 @@ # For extensions under Cygwin, Python's library directory must be # appended to library_dirs - if sys.platform[:6] == 'cygwin': + if sys.platform[:6] == 'cygwin' or self.plat_name.startswith(('mingw')): if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions config_dir_name = os.path.basename(sysconfig.get_config_var('LIBPL'))