diff -urN FreeImage-orig/Makefile.fip FreeImage/Makefile.fip
--- FreeImage-orig/Makefile.fip	2015-03-10 15:03:56 +0800
+++ FreeImage/Makefile.fip	2021-11-01 18:34:10 +0800
@@ -3,6 +3,10 @@
 # This file can be generated by ./genfipsrclist.sh
 include fipMakefile.srcs
 
+AR = ar
+RC = windres
+PKGCONFIG = pkg-config
+
 # General configuration variables:
 DESTDIR ?= /
 INCDIR ?= $(DESTDIR)/usr/include
@@ -24,22 +28,20 @@
 CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
 CFLAGS += $(INCLUDE)
 CXXFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
+CXXFLAGS += -DFIP_EXPORTS -DOPJ_EXPORTS
 # LibJXR
 CXXFLAGS += -D__ANSI__
 CXXFLAGS += $(INCLUDE)
-
-ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
-	CFLAGS += -fPIC
-	CXXFLAGS += -fPIC
-endif
+LDFLAGS ?=
+LDFLAGS += -LDist -lfreeimage-$(VER_MAJOR) -lgdi32
 
 TARGET  = freeimageplus
 STATICLIB = lib$(TARGET).a
-SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
-LIBNAME	= lib$(TARGET).so
-VERLIBNAME = $(LIBNAME).$(VER_MAJOR)
+SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).dll
+IMPORTLIB = lib$(TARGET).dll.a
 HEADER = Source/FreeImage.h
 HEADERFIP = Wrapper/FreeImagePlus/FreeImagePlus.h
+RCFILE = Wrapper/FreeImagePlus/FreeImagePlus.rc
 
 
 default: all
@@ -49,7 +51,7 @@
 dist: FreeImage
 	mkdir -p Dist
 	cp *.a Dist/
-	cp *.so Dist/
+	cp *.dll Dist/
 	cp Source/FreeImage.h Dist/
 	cp Wrapper/FreeImagePlus/FreeImagePlus.h Dist/
 
@@ -64,21 +66,13 @@
 .cpp.o:
 	$(CXX) $(CXXFLAGS) -c $< -o $@
 
+%.coff: %.rc
+	$(RC) $(RCFLAGS) -o $@ $<
+
 $(STATICLIB): $(MODULES)
-	$(AR) r $@ $(MODULES)
+	$(AR) rs $@ $(MODULES)
 
 $(SHAREDLIB): $(MODULES)
-	$(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
-
-install:
-	install -d $(INCDIR) $(INSTALLDIR)
-	install -m 644 -o root -g root $(HEADER) $(INCDIR)
-	install -m 644 -o root -g root $(HEADERFIP) $(INCDIR)
-	install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
-	install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
-	ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
-	ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)	
+	$(CC) -shared -Wl,--out-implib,$(IMPORTLIB) -o $@ $(MODULES) $(LDFLAGS) $(LIBRARIES)
 
-clean:
-	rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
 
diff -urN FreeImage-orig/Makefile.gnu FreeImage/Makefile.gnu
--- FreeImage-orig/Makefile.gnu	2015-03-10 15:04:00 +0800
+++ FreeImage/Makefile.gnu	2021-11-01 18:33:44 +0800
@@ -3,6 +3,10 @@
 # This file can be generated by ./gensrclist.sh
 include Makefile.srcs
 
+AR = ar
+RC = windres
+PKGCONFIG = pkg-config
+
 # General configuration variables:
 DESTDIR ?= /
 INCDIR ?= $(DESTDIR)/usr/include
@@ -16,6 +20,7 @@
 MODULES = $(SRCS:.c=.o)
 MODULES := $(MODULES:.cpp=.o)
 CFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
+CFLAGS += -D__ANSI__ -DFREEIMAGE_EXPORTS $(INCLUDE) -I$(shell ${PKGCONFIG} --variable pc_system_includedirs pkg-config)/jxrlib $(shell ${PKGCONFIG} --cflags OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib)
 # OpenJPEG
 CFLAGS += -DOPJ_STATIC
 # LibRaw
@@ -25,19 +30,16 @@
 CFLAGS += $(INCLUDE)
 CXXFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
 # LibJXR
-CXXFLAGS += -D__ANSI__
-CXXFLAGS += $(INCLUDE)
+CXXFLAGS += -D__ANSI__ -DFREEIMAGE_EXPORTS -DOPJ_EXPORTS
+CXXFLAGS += $(INCLUDE) -I$(shell ${PKGCONFIG} --variable pc_system_includedirs pkg-config)/jxrlib $(shell ${PKGCONFIG} --cflags OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib)
 
-ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
-	CFLAGS += -fPIC
-	CXXFLAGS += -fPIC
-endif
+LDFLAGS ?=
+LDFLAGS += $(shell ${PKGCONFIG} --libs OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib) -ljpeg -ljpegxr -ljxrglue
 
 TARGET  = freeimage
 STATICLIB = lib$(TARGET).a
-SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
-LIBNAME	= lib$(TARGET).so
-VERLIBNAME = $(LIBNAME).$(VER_MAJOR)
+SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).dll
+IMPORTLIB = lib$(TARGET).dll.a
 HEADER = Source/FreeImage.h
 
 
@@ -49,7 +51,7 @@
 dist: FreeImage
 	mkdir -p Dist
 	cp *.a Dist/
-	cp *.so Dist/
+	cp *.dll Dist/
 	cp Source/FreeImage.h Dist/
 
 dos2unix:
@@ -64,20 +66,9 @@
 	$(CXX) $(CXXFLAGS) -c $< -o $@
 
 $(STATICLIB): $(MODULES)
-	$(AR) r $@ $(MODULES)
+	$(AR) rs $@ $(MODULES)
 
 $(SHAREDLIB): $(MODULES)
-	$(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
-
-install:
-	install -d $(INCDIR) $(INSTALLDIR)
-	install -m 644 -o root -g root $(HEADER) $(INCDIR)
-	install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
-	install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
-	ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
-	ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)	
-#	ldconfig
+	$(CC) -shared -Wl,--out-implib,$(IMPORTLIB) -o $@ $(MODULES) $(LDFLAGS) $(LIBRARIES)
 
-clean:
-	rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
 
