--- blender-2.81a/source/blender/blendthumb/CMakeLists.txt.orig	2019-12-08 12:20:39.042905800 +0300
+++ blender-2.81a/source/blender/blendthumb/CMakeLists.txt	2019-12-08 12:20:45.308264200 +0300
@@ -29,11 +29,11 @@
 )
 
 add_library(BlendThumb SHARED ${SRC})
-target_link_libraries(BlendThumb ${ZLIB_LIBRARIES})
+target_link_libraries(BlendThumb ${ZLIB_LIBRARIES} shlwapi windowscodecs)
 
 install(
   FILES $<TARGET_FILE:BlendThumb>
   COMPONENT Blender
-  DESTINATION "."
+  DESTINATION "bin"
 )
 
--- blender-2.81a/source/blender/blenlib/intern/winstuff.c.orig	2019-12-08 12:27:42.467124300 +0300
+++ blender-2.81a/source/blender/blenlib/intern/winstuff.c	2019-12-08 12:30:11.497648300 +0300
@@ -1,4 +1,5 @@
 /*
+/*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -172,7 +173,11 @@
 
   BLI_getInstallationDir(InstallDir);
   GetSystemDirectory(SysDir, FILE_MAXDIR);
+#ifdef __MINGW32__
+  ThumbHandlerDLL = "libBlendThumb.dll";
+#else
   ThumbHandlerDLL = "BlendThumb.dll";
+#endif
   snprintf(
       RegCmd, MAX_PATH * 2, "%s\\regsvr32 /s \"%s\\%s\"", SysDir, InstallDir, ThumbHandlerDLL);
   system(RegCmd);
--- blender-2.81a/source/blender/blendthumb/src/BlenderThumb.cpp.orig	2019-12-08 12:08:05.045779600 +0300
+++ blender-2.81a/source/blender/blendthumb/src/BlenderThumb.cpp	2019-12-08 12:32:20.265013400 +0300
@@ -17,8 +17,11 @@
 #include <new>
 #include <shlwapi.h>
 #include <thumbcache.h>  // For IThumbnailProvider.
+#include <algorithm>
 
+#ifdef _MSC_VER
 #pragma comment(lib, "shlwapi.lib")
+#endif
 
 // this thumbnail provider implements IInitializeWithStream to enable being hosted
 // in an isolated process for robustness
@@ -137,7 +140,7 @@
     //_pStream->Read(&dest_size,4,&BytesRead); // dest
     dest_size = 1024 * 70;  // thumbnail is currently always inside the first 65KB...if it moves or
                             // enlargens this line will have to change or go!
-    source_size = (uLong)max(SeekPos.QuadPart, dest_size);  // for safety, assume no compression
+    source_size = (uLong)std::max((uLong)SeekPos.QuadPart, dest_size);  // for safety, assume no compression
 
     // Input
     Bytef *src = new Bytef[source_size];
@@ -264,7 +267,7 @@
 
     // Scale down if required
     if ((unsigned)width > cx || (unsigned)height > cx) {
-      float scale = 1.0f / (max(width, height) / (float)cx);
+      float scale = 1.0f / (std::max(width, height) / (float)cx);
       LONG NewWidth = (LONG)(width * scale);
       LONG NewHeight = (LONG)(height * scale);
 
