--- a/qtimageformats/src/plugins/imageformats/mng/qmnghandler.cpp
+++ b/qtimageformats/src/plugins/imageformats/mng/qmnghandler.cpp
@@ -43,7 +43,20 @@
 #include "qvariant.h"
 #include "qcolor.h"
 
+#ifdef QT_STATICPLUGIN
+#undef MNG_DLL
+#undef MNG_USE_DLL
+#define MNG_SUPPORT_WRITE
+#define MNG_ACCESS_CHUNKS
+#define MNG_SUPPORT_DISPLAY
+#define MNG_SUPPORT_READ
+#else
+#ifdef _WIN32
+#define MNG_USE_DLL
+#else
 #define MNG_USE_SO
+#endif
+#endif
 #include <libmng.h>
 
 QT_BEGIN_NAMESPACE
@@ -80,7 +84,7 @@
     QMngHandler *q_ptr;
 };
 
-static mng_bool myerror(mng_handle /*hMNG*/,
+static mng_bool MNG_DECL myerror(mng_handle /*hMNG*/,
     mng_int32   iErrorcode,
     mng_int8    /*iSeverity*/,
     mng_chunkid iChunkname,
@@ -99,29 +103,29 @@
     return MNG_TRUE;
 }
 
-static mng_ptr myalloc(mng_size_t iSize)
+static mng_ptr MNG_DECL myalloc(mng_size_t iSize)
 {
     return (mng_ptr)calloc(1, iSize);
 }
 
-static void myfree(mng_ptr pPtr, mng_size_t /*iSize*/)
+static void MNG_DECL MNG_DECL myfree(mng_ptr pPtr, mng_size_t /*iSize*/)
 {
     free(pPtr);
 }
 
-static mng_bool myopenstream(mng_handle)
+static mng_bool MNG_DECL myopenstream(mng_handle)
 {
     return MNG_TRUE;
 }
 
-static mng_bool myclosestream(mng_handle hMNG)
+static mng_bool MNG_DECL myclosestream(mng_handle hMNG)
 {
     QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
     pMydata->haveReadAll = true;
     return MNG_TRUE;
 }
 
-static mng_bool myreaddata(mng_handle hMNG,
+static mng_bool MNG_DECL myreaddata(mng_handle hMNG,
                     mng_ptr    pBuf,
                     mng_uint32 iSize,
                     mng_uint32p pRead)
@@ -130,7 +134,7 @@
     return pMydata->readData(pBuf, iSize, pRead);
 }
 
-static mng_bool mywritedata(mng_handle hMNG,
+static mng_bool MNG_DECL mywritedata(mng_handle hMNG,
                      mng_ptr pBuf,
                      mng_uint32 iSize,
                      mng_uint32p pWritten)
@@ -139,7 +143,7 @@
     return pMydata->writeData(pBuf, iSize, pWritten);
 }
 
-static mng_bool myprocessheader(mng_handle hMNG,
+static mng_bool MNG_DECL myprocessheader(mng_handle hMNG,
                                 mng_uint32 iWidth,
                                 mng_uint32 iHeight)
 {
@@ -147,14 +151,14 @@
     return pMydata->processHeader(iWidth, iHeight);
 }
 
-static mng_ptr mygetcanvasline(mng_handle hMNG,
+static mng_ptr MNG_DECL mygetcanvasline(mng_handle hMNG,
                                mng_uint32 iLinenr)
 {
     QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
     return (mng_ptr)pMydata->image.scanLine(iLinenr);
 }
 
-static mng_bool myrefresh(mng_handle /*hMNG*/,
+static mng_bool MNG_DECL myrefresh(mng_handle /*hMNG*/,
                           mng_uint32 /*iX*/,
                           mng_uint32 /*iY*/,
                           mng_uint32 /*iWidth*/,
@@ -163,13 +167,13 @@
     return MNG_TRUE;
 }
 
-static mng_uint32 mygettickcount(mng_handle hMNG)
+static mng_uint32 MNG_DECL mygettickcount(mng_handle hMNG)
 {
     QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
     return pMydata->elapsed++;
 }
 
-static mng_bool mysettimer(mng_handle hMNG,
+static mng_bool MNG_DECL mysettimer(mng_handle hMNG,
                            mng_uint32 iMsecs)
 {
     QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
@@ -178,7 +182,7 @@
     return MNG_TRUE;
 }
 
-static mng_bool myprocessterm(mng_handle hMNG,
+static mng_bool MNG_DECL myprocessterm(mng_handle hMNG,
                         mng_uint8   iTermaction,
                         mng_uint8   /*iIteraction*/,
                         mng_uint32  /*iDelay*/,
@@ -190,7 +194,7 @@
     return MNG_TRUE;
 }
 
-static mng_bool mytrace(mng_handle,
+static mng_bool MNG_DECL mytrace(mng_handle,
                         mng_int32   iFuncnr,
                         mng_int32   iFuncseq,
                         mng_pchar   zFuncname)
--- a/qtimageformats/cmake/FindLibmng.cmake
+++ b/qtimageformats/cmake/FindLibmng.cmake
@@ -11,6 +11,11 @@
     if(TARGET PkgConfig::Libmng)
         add_library(Libmng::Libmng INTERFACE IMPORTED)
         target_link_libraries(Libmng::Libmng INTERFACE PkgConfig::Libmng)
+        if(BUILD_SHARED_LIBS)
+            target_compile_definitions(Libmng::Libmng INTERFACE -DMNG_DLL)
+        else()
+            target_compile_options(Libmng::Libmng INTERFACE -UMNG_DLL -UMNG_USE_DLL)
+        endif()
         set(Libmng_FOUND TRUE)
     endif()
 endif()
@@ -25,6 +28,9 @@
             IMPORTED_LOCATION ${LIBMNG_LIBRARY}
             INTERFACE_INCLUDE_DIRECTORIES ${LIBMNG_INCLUDE_DIR}
         )
+        if(BUILD_SHARED_LIBS)
+            target_compile_definitions(Libmng::Libmng INTERFACE -DMNG_DLL)
+        endif()
     endif()
 
     include(FindPackageHandleStandardArgs)
