--- a/ixml/CMakeLists.txt
+++ b/ixml/CMakeLists.txt
@@ -40,7 +40,7 @@
 		PRIVATE $<$<BOOL:${IXML_HAVE_SCRIPTSUPPORT}>:IXML_HAVE_SCRIPTSUPPORT>
 		PRIVATE LIBUPNP_EXPORTS
 		PUBLIC $<$<BOOL:${MSVC}>:UPNP_USE_MSVCPP>
-		PUBLIC $<$<BOOL:${MSVC}>:LIBUPNP_EXPORTS>
+		PUBLIC $<$<BOOL:${WIN32}>:LIBUPNP_EXPORTS>
 		PUBLIC $<$<BOOL:${_LARGE_FILES}>:_LARGE_FILES>
 		PUBLIC $<$<BOOL:${_FILE_OFFSET_BITS}>:_FILE_OFFSET_BITS=64>
 		PUBLIC $<IF:$<CONFIG:Debug>,DEBUG,NDEBUG>
--- a/upnp/inc/UpnpGlobal.h
+++ b/upnp/inc/UpnpGlobal.h
@@ -20,7 +20,7 @@
 	/*
 	 * UPNP_EXPORT_SPEC
 	 */
-	#if defined _MSC_VER || defined __BORLANDC__
+	#if defined _MSC_VER || defined __BORLANDC__ || __MINGW32__
 		#ifdef UPNP_STATIC_LIB
 			#define UPNP_EXPORT_SPEC
 		#else /* UPNP_STATIC_LIB */
