diff --git a/lib/meson.build b/lib/meson.build
index 02487b04c1d6f3d43b1cfc44266b3d8e603952b3..21f72ad0f64effaf02807770d811238344ea2ecf 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -17,5 +17,6 @@ cmplib_sources = files([
 cmp_lib = static_library('cmp_lib',
   sources : cmplib_sources,
   include_directories : incdir,
-  c_args : ['-DDEBUGLEVEL=1']
+  c_args : ['-DDEBUGLEVEL=1'], 
+  install : 'true' # linking under windows mingw only works if this is set
 )
diff --git a/meson.build b/meson.build
index 59f2c059008d0bf6c1ab888e4a20a18d8800356b..295699f570417cf8abde2ee003ccf93f3f823318 100644
--- a/meson.build
+++ b/meson.build
@@ -4,11 +4,12 @@ project('cmp_tool', 'c',
   default_options : ['warning_level=3', 'c_std=gnu99']
 )
 
-if host_machine.system() == 'windows' and cc.get_id() == 'gcc'
+if host_machine.system() == 'windows' and meson.get_compiler('c').get_id() == 'gcc'
   # by default, MinGW on win32 behaves as if it ignores __attribute__((packed)),
   # you need to add -mno-ms-bitfields to make it work as expected.
   # See: https://wintermade.it/blog/posts/__attribute__packed-on-windows-is-ignored-with-mingw.html
   add_project_arguments('-mno-ms-bitfields', language : 'c')
+  add_global_link_arguments('-static', language: 'c')
 endif
 
 subdir('include')
diff --git a/test/cmp_tool/cmp_tool_integration_test.py b/test/cmp_tool/cmp_tool_integration_test.py
index 72d32c47ab34f866af6e12b4c54e1867772dc86a..9804d4108571016edd68681526b3f9ea7bf384fa 100755
--- a/test/cmp_tool/cmp_tool_integration_test.py
+++ b/test/cmp_tool/cmp_tool_integration_test.py
@@ -1136,6 +1136,11 @@ def test_model_fiel_erros():
                          "longlonglonglonglonglonglonglonglonglonglonglonglong"
                          "longlonglonglonglonglonglonglonglonglonglonglonglong"
                          "longlonglonglonglonglonglonglonglonglong")
+        if sys.platform == 'win32' or sys.platform == 'cygwin':
+          output_prefix = ("longlonglonglonglonglonglonglonglonglonglonglonglong"
+                           "longlonglonglonglonglonglonglonglonglonglonglonglong"
+                           "longlonglonglonglonglonglonglonglonglonglonglonglong"
+                           "longlonglonglonglonglonglonglonglonglonglong")
         returncode, stdout, stderr = call_cmp_tool(
             " -c "+cfg_file_name+" -d "+data_file_name + " -m "+model_file_name+" -o "+output_prefix)
         assert(returncode == EXIT_FAILURE)
@@ -1147,8 +1152,10 @@ def test_model_fiel_erros():
                "Compress data ... DONE\n" +
                "Write compressed data to file %s.cmp ... DONE\n" %(output_prefix) +
                "Write updated model to file %s_upmodel.dat ... FAILED\n" %(output_prefix))
-        assert(stderr == "cmp_tool: %s_upmodel.dat: File name too long\n" % (output_prefix))
-        #
+        if sys.platform == 'win32' or sys.platform == 'cygwin':
+          assert(stderr == "cmp_tool: %s_upmodel.dat: No such file or directory\n" % (output_prefix))
+        else:
+          assert(stderr == "cmp_tool: %s_upmodel.dat: File name too long\n" % (output_prefix))
 
     finally:
         del_file(data_file_name)
diff --git a/test/meson.build b/test/meson.build
index 617df9c3f1d057f3209fc299e01e1a6a818b4cd7..ea06655afd9ec23492e9601553d7835e58d038b9 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -32,7 +32,7 @@ endif
 
 subdir('cmp_tool')
 
-cunit_dep = dependency('cunit')
+cunit_dep = dependency('cunit', required : false)
 if cunit_dep.found()
   subdir('cmp_icu')
 endif