diff --git a/mingw-w64-64.txt b/mingw-w64-64.txt
index 773be92376afa65261c519bae973fca17e8e3cc9..0cb48e3b3bd0871da0086369358ed65efef82f2a 100644
--- a/mingw-w64-64.txt
+++ b/mingw-w64-64.txt
@@ -15,8 +15,11 @@ cpu_family = 'x86_64'
 cpu = 'x86_64'
 endian = 'little'
 
-[cmake]
+[built-in options]
+# for clock_gettime function
+c_link_args = ['-lwinpthread']
 
+[cmake]
 CMAKE_BUILD_WITH_INSTALL_RPATH     = 'ON'
 CMAKE_FIND_ROOT_PATH_MODE_PROGRAM  = 'NEVER'
 CMAKE_FIND_ROOT_PATH_MODE_LIBRARY  = 'ONLY'
diff --git a/test/cmp_tool/cmp_tool_integration_test.py b/test/cmp_tool/cmp_tool_integration_test.py
index 9d40abefc597e4cbecde941c951210db17bcb9d7..cf8309529cb7eb5625cbc1872f1796dff9c8c7a3 100755
--- a/test/cmp_tool/cmp_tool_integration_test.py
+++ b/test/cmp_tool/cmp_tool_integration_test.py
@@ -6,6 +6,7 @@ import sys
 import os
 import math
 import shutil
+from pathlib import Path
 
 from datetime import datetime
 from datetime import timedelta
@@ -22,12 +23,26 @@ IMAGETTE_HEADER_SIZE = GENERIC_HEADER_SIZE+4
 IMAGETTE_ADAPTIVE_HEADER_SIZE = GENERIC_HEADER_SIZE+12
 NON_IMAGETTE_HEADER_SIZE = GENERIC_HEADER_SIZE+32
 
+WINE_TEST_SETUP = False
+my_env=None
+if sys.platform != 'win32' and sys.platform != 'cygwin':
+    if Path('cmp_tool.exe').exists():
+        # try to detect cross compile setup
+        # and use wine to run windows executable
+        WINE_TEST_SETUP = True
+        # disable wine debug output
+        my_env = os.environ.copy()
+        my_env["WINEDEBUG"] = f"-all"
 
 def call_cmp_tool(args):
-    args = shlex.split("./cmp_tool " + args)
+    if WINE_TEST_SETUP:
+        args = shlex.split("wine64 cmp_tool.exe " + args)
+    else:
+        args = shlex.split("./cmp_tool " + args)
+    print(args)
 
     try:
-        with subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) as proc:
+        with subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, env=my_env) as proc:
             stdout, stderr = proc.communicate()
             return (proc.returncode, stdout, stderr)
     except:
@@ -196,7 +211,7 @@ VERSION = stdout.split()[2]
 returncode, stdout, stderr = call_cmp_tool("")
 assert(returncode == EXIT_FAILURE)
 assert(stderr == "")
-start_parh = stdout.rpartition('usage: ')[2] 
+start_parh = stdout.rpartition('usage: ')[2]
 PATH_CMP_TOOL = start_parh[: start_parh.find(' [options] [<argument>]\n')]
 
 HELP_STRING = \
@@ -254,17 +269,17 @@ def test_invalid_option():
         assert(returncode == EXIT_FAILURE)
         assert(stdout == HELP_STRING)
         if arg == '-q':
-            if sys.platform == 'linux':
-                assert(stderr == "%s: invalid option -- 'q'\n" % (PATH_CMP_TOOL))
-            elif sys.platform == 'win32' or sys.platform == 'cygwin':
+            if sys.platform == 'win32' or sys.platform == 'cygwin' or WINE_TEST_SETUP:
                 assert(stderr == "%s: unknown option -- q\n" % (PATH_CMP_TOOL))
+            elif sys.platform == 'linux':
+                assert(stderr == "%s: invalid option -- 'q'\n" % (PATH_CMP_TOOL))
             else:
                 assert(stderr == "cmp_tool: invalid option -- q\n")
         else:
-            if sys.platform == 'linux':
-                assert(stderr == "%s: unrecognized option '--not_used'\n" % (PATH_CMP_TOOL))
-            elif sys.platform == 'win32' or sys.platform == 'cygwin':
+            if sys.platform == 'win32' or sys.platform == 'cygwin' or WINE_TEST_SETUP:
                 assert(stderr == "%s: unknown option -- not_used\n" % (PATH_CMP_TOOL))
+            elif sys.platform == 'linux':
+                assert(stderr == "%s: unrecognized option '--not_used'\n" % (PATH_CMP_TOOL))
             else:
                 assert(stderr == "cmp_tool: unrecognized option `--not_used'\n")
 
@@ -1303,7 +1318,7 @@ 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))
-        if sys.platform == 'win32' or sys.platform == 'cygwin':
+        if sys.platform == 'win32' or sys.platform == 'cygwin' or WINE_TEST_SETUP:
           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))