diff -Naur Python-3.8.0-orig/Lib/distutils/command/build_ext.py Python-3.8.0/Lib/distutils/command/build_ext.py
--- Python-3.8.0-orig/Lib/distutils/command/build_ext.py	2019-10-22 10:03:03.194158500 +0300
+++ Python-3.8.0/Lib/distutils/command/build_ext.py	2019-10-22 10:04:11.803079000 +0300
@@ -218,7 +218,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'))
