The issue was library libwinpthread-1.dll was missing in the system at runtime in the native code. My solution was to link statically libwinpthread and all now works fine!
libwinpthread-1.dll
libwinpthread