diff --git a/m4/ax_matio.m4 b/m4/ax_matio.m4
index caab9ef4c70ab3d1141d075a3b116f89555b9cf7..9a4d56284d537aeb020b6020395f06549109144f 100644
--- a/m4/ax_matio.m4
+++ b/m4/ax_matio.m4
@@ -1,6 +1,6 @@
 dnl Detect the MATIO Library.
 dnl
-dnl Copyright © 2012-2021 Dynare Team
+dnl Copyright © 2012-2023 Dynare Team
 dnl
 dnl This file is part of Dynare.
 dnl
@@ -22,6 +22,8 @@ AC_DEFUN([AX_MATIO],
 AC_ARG_WITH(matio, AS_HELP_STRING([--with-matio=DIR], [prefix to MATIO installation]),
             matio_prefix="$withval", matio_prefix="")
 
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
   has_matio=yes
 
   if test -n "$matio_prefix"; then
@@ -40,15 +42,19 @@ AC_ARG_WITH(matio, AS_HELP_STRING([--with-matio=DIR], [prefix to MATIO installat
   CPPFLAGS="$CPPFLAGS_MATIO $CPPFLAGS"
   LDFLAGS="$LDFLAGS_MATIO $LDFLAGS"
 
-  dnl Workaround for the matio from RHEL 6 + EPEL 6
-  dnl If detected, libz and libhdf5 are added to LIBS, used for matio test
-  LIBS=""
-  AC_CHECK_LIB([z], [compress])
-  dnl szip is needed under MSYS2
-  AC_CHECK_LIB([szip], [SZ_Compress])
-  dnl szip is needed for static linking on macOS (it's called libsz on macOS)
-  AC_CHECK_LIB([sz], [SZ_Compress])
-  AC_CHECK_LIB([hdf5], [H5Fcreate])
+  dnl Under Windows and macOS, add hdf5 and its dependencies since we are linking statically
+  case ${host_os} in
+    *mingw32*)
+          dnl Partly inspired by /mingw64/lib/pkgconfig/{hdf5,libcurl}.pc (in particular for the system libraries)
+          LIBS="-lhdf5 -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -lunistring -liconv -lbcrypt -ladvapi32 -lcrypt32 -lbcrypt -lgdi32 -lwldap32 -lzstd -lbrotlidec -lbrotlicommon -lssl -lcrypto -lws2_32 -lz -lsz"
+          ;;
+    *darwin*)
+          LIBS="-lhdf5 -lz -lsz"
+          ;;
+    *)
+          LIBS=""
+          ;;
+  esac
 
   AC_CHECK_HEADER([matio.h], [], [has_matio=no])
   AC_CHECK_LIB([matio], [Mat_Open], [LIBADD_MATIO="-lmatio $LIBS"], [has_matio=no])
diff --git a/windows/deps/Makefile b/windows/deps/Makefile
index 801599346a0801835815e92dbdad3d140b53c0d5..bc28af4003f64d3105a7604f6ae10a7ee937b5be 100644
--- a/windows/deps/Makefile
+++ b/windows/deps/Makefile
@@ -170,7 +170,7 @@ msys2: lib64-msys2 mingw64
 
 MSYS2_EXCLUDES := --exclude .MTREE --exclude .BUILDINFO --exclude .PKGINFO
 
-lib64-msys2: tarballs/mingw-w64-x86_64-boost-$(MINGW64_BOOST_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-gsl-$(MINGW64_GSL_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-matio-$(MINGW64_MATIO_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-zlib-$(MINGW64_ZLIB_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-hdf5-$(MINGW64_HDF5_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libaec-$(MINGW64_LIBAEC_VERSION)-any.pkg.tar.zst
+lib64-msys2: tarballs/mingw-w64-x86_64-boost-$(MINGW64_BOOST_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-gsl-$(MINGW64_GSL_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-matio-$(MINGW64_MATIO_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-zlib-$(MINGW64_ZLIB_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-hdf5-$(MINGW64_HDF5_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libaec-$(MINGW64_LIBAEC_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-openssl-$(MINGW64_OPENSSL_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-curl-$(MINGW64_CURL_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-zstd-$(MINGW64_ZSTD_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-brotli-$(MINGW64_BROTLI_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libidn2-$(MINGW64_LIBIDN2_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libpsl-$(MINGW64_LIBPSL_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libssh2-$(MINGW64_LIBSSH2_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-nghttp2-$(MINGW64_NGHTTP2_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libiconv-$(MINGW64_LIBICONV_VERSION)-any.pkg.tar.zst tarballs/mingw-w64-x86_64-libunistring-$(MINGW64_LIBUNISTRING_VERSION)-any.pkg.tar.zst
 	rm -rf $@
 	mkdir $@
 	for f in $^; do tar xf $$f --directory $@ --strip-components 1 $(MSYS2_EXCLUDES); done
diff --git a/windows/deps/versions.mk b/windows/deps/versions.mk
index 6c288b5d6d7c7028064d40ca6f122bc4ad319445..715b68b8c649c09e4329a43cb47aff55a48fd1a4 100644
--- a/windows/deps/versions.mk
+++ b/windows/deps/versions.mk
@@ -32,12 +32,52 @@ MINGW64_ZLIB_VERSION = 1.2.13-3
 
 # Dependency of matio
 # pacman -Ss mingw-w64-x86_64-hdf5
-MINGW64_HDF5_VERSION = 1.12.2-2
+MINGW64_HDF5_VERSION = 1.14.0-4
 
 # Dependency of HDF5 (provides szip library)
 # pacman -Ss mingw-w64-x86_64-libaec
 MINGW64_LIBAEC_VERSION = 1.0.6-2
 
+# Dependency of HDF5
+# pacman -Ss mingw-w64-x86_64-openssl
+MINGW64_OPENSSL_VERSION = 3.1.0-1
+
+# Dependency of HDF5
+# pacman -Ss mingw-w64-x86_64-curl
+MINGW64_CURL_VERSION = 7.88.1-2
+
+# Dependency of curl (and of the MinGW compiler)
+# pacman -Ss mingw-w64-x86_64-zstd
+MINGW64_ZSTD_VERSION = 1.5.4-1
+
+# Dependency of curl
+# pacman -Ss mingw-w64-x86_64-brotli
+MINGW64_BROTLI_VERSION = 1.0.9-5
+
+# Dependency of curl
+# pacman -Ss mingw-w64-x86_64-libpsl
+MINGW64_LIBPSL_VERSION = 0.21.2-4
+
+# Dependency of curl and of libpsl
+# pacman -Ss mingw-w64-x86_64-libidn2
+MINGW64_LIBIDN2_VERSION = 2.3.4-1
+
+# Dependency of curl
+# pacman -Ss mingw-w64-x86_64-libssh2
+MINGW64_LIBSSH2_VERSION = 1.10.0-2
+
+# Dependency of curl
+# pacman -Ss mingw-w64-x86_64-nghttp2
+MINGW64_NGHTTP2_VERSION = 1.52.0-1
+
+# Dependency of libpsl and libunistring (and of the MinGW compiler)
+# pacman -Ss mingw-w64-x86_64-libiconv
+MINGW64_LIBICONV_VERSION = 1.17-3
+
+# Dependency of libpsl and libidn2
+# pacman -Ss mingw-w64-x86_64-libunistring
+MINGW64_LIBUNISTRING_VERSION = 1.1-1
+
 ## MinGW packages for the embedded compiler
 
 # pacman -Ss mingw-w64-x86_64-gcc$
@@ -58,9 +98,6 @@ MINGW64_CRT_VERSION = 10.0.0.r234.g283e5b23a-1
 # pacman -Ss mingw-w64-x86_64-winpthreads-git
 MINGW64_WINPTHREADS_VERSION = 10.0.0.r234.g283e5b23a-1
 
-# pacman -Ss mingw-w64-x86_64-zstd
-MINGW64_ZSTD_VERSION = 1.5.4-1
-
 # pacman -Ss mingw-w64-x86_64-isl
 MINGW64_ISL_VERSION = 0.25-1
 
@@ -70,8 +107,5 @@ MINGW64_MPC_VERSION = 1.3.1-1
 # pacman -Ss mingw-w64-x86_64-mpfr
 MINGW64_MPFR_VERSION = 4.2.0-1
 
-# pacman -Ss mingw-w64-x86_64-libiconv
-MINGW64_LIBICONV_VERSION = 1.17-3
-
 # pacman -Ss mingw-w64-x86_64-windows-default-manifest
 MINGW64_WINDOWS_DEFAULT_MANIFEST_VERSION = 6.4-4