SNAPHU 2.0.7 - Windows x64 MSYS2/GCC15 Build
================================================

This package contains an unofficial Windows x64 build of SNAPHU 2.0.7.

SNAPHU itself is developed and maintained by its original upstream author(s).
This Windows package is only a convenience build prepared for use with ESA SNAP /
SNAP13 on Windows systems where the bundled SNAPHU version may still be 2.0.4.

This is NOT an official upstream SNAPHU release.


Package contents
----------------

bin/
  snaphu.exe       Windows x64 executable built from SNAPHU 2.0.7 source
  msys-2.0.dll     MSYS2 runtime DLL required by this executable

config/
  Original SNAPHU configuration files

man/
  Original SNAPHU manual files

README
  Original upstream SNAPHU README

README_releasenotes.txt
  Original upstream SNAPHU release notes

README_WINDOWS_BUILD.txt
  This file


Build environment
-----------------

Operating system:
  Windows x64

Build environment:
  MSYS2 MSYS shell

Compiler:
  C:/msys64/usr/bin/gcc.exe

Compiler target observed:
  x86_64-pc-cygwin

Compiler version used:
  GCC 15.2.0

Build command:
  make clean
  make

The generated executable was:

  bin/snaphu.exe

The executable was tested successfully with:

  snaphu.exe

Expected output begins with:

  snaphu v2.0.7


Important note about MSYS2
--------------------------

This build was compiled using the MSYS2 MSYS toolchain, not the UCRT64 or MINGW64
toolchain.

The correct compiler for this source tree is:

  C:/msys64/usr/bin/gcc.exe

This is important because SNAPHU uses POSIX-style headers and functionality,
including:

  sys/wait.h
  sys/resource.h
  unistd.h

These headers are available in the MSYS environment but are not available in the
same way in the native MinGW/UCRT64 toolchains.


GCC 15 compatibility patch
--------------------------

The source file:

  src/snaphu_tile.c

was patched for compatibility with GCC 15.

The patch changes temporary function pointer declarations in GrowRegions() from
old-style untyped function pointers to explicitly typed function pointers.

Original form:

  void (*tempcalccostfnptr)();
  long (*tempevalcostfnptr)();

Patched form:

  void (*tempcalccostfnptr)(void **, long, long, long, long, long,
                            paramT *, long *, long *);
  long (*tempevalcostfnptr)(void **, short **, long, long, long, paramT *);

This avoids GCC 15 errors related to incompatible function pointer assignments.


Windows runtime dependency
--------------------------

The executable depends on:

  msys-2.0.dll

This DLL must be present in the same folder as snaphu.exe when SNAPHU is launched
outside the MSYS2 shell, for example from SNAP13.

The DLL used for this build was copied from:

  C:/msys64/usr/bin/msys-2.0.dll

Dependency check command used:

  ldd bin/snaphu.exe

Observed non-Windows dependency:

  msys-2.0.dll


Installation for SNAP / SNAP13
------------------------------

Option 1 - Use this folder directly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Configure SNAP/SNAPHU to use:

  <this-package-folder>/bin/snaphu.exe

For example:

  C:/Users/<USER>/.snap/auxdata/snaphu-v2.0.7_win64/bin/snaphu.exe


Option 2 - Replace the older SNAP bundled executable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If SNAP13 still points to an older folder such as:

  C:/Users/<USER>/.snap/auxdata/snaphu-v2.0.4_win64/bin/

make a backup first:

  snaphu.exe -> snaphu_2.0.4_backup.exe

Then copy these files into that same bin folder:

  snaphu.exe
  msys-2.0.dll

After replacement, SNAP will still use the old folder path, but the executable
inside it will be SNAPHU 2.0.7.


PowerShell test
---------------

Before using the executable from SNAP, test it from normal Windows PowerShell:

  & "C:\Users\<USER>\.snap\auxdata\snaphu-v2.0.7_win64\bin\snaphu.exe"

Expected output:

  snaphu v2.0.7
  usage: snaphu [options] infile linelength [options]

If Windows reports that msys-2.0.dll is missing, copy msys-2.0.dll into the same
folder as snaphu.exe.


Build artifacts
---------------

The .o files generated in the src/ directory are temporary object files produced
by the compiler.

Examples:

  snaphu_tile.o
  snaphu_solver.o
  snaphu_io.o
  snaphu_util.o
  snaphu_cost.o
  snaphu_cs2.o

They are not required in the final Windows package and can be removed with:

  make clean


Version note
------------

This package keeps the upstream SNAPHU version number:

  snaphu v2.0.7

It should not be presented as an official SNAPHU 2.0.8 release.

A suitable package name is:

  snaphu-v2.0.7_win64_msys2_gcc15

or:

  snaphu-v2.0.7_win64_gcc15_patched


Purpose of this build
---------------------

This Windows build was prepared because SNAP13 may still install the older
SNAPHU 2.0.4 bundle automatically.

SNAPHU 2.0.7 includes upstream fixes after 2.0.4, including fixes related to
tile mode, masked regions, possible infinite loops, and connected components.

This build allows Windows SNAP/SNAP13 users to run SNAPHU 2.0.7 without manually
compiling it themselves.


Disclaimer
----------

This is an unofficial convenience build.

For official source code, documentation, citation requirements, licensing terms,
and bug reporting instructions, refer to the upstream SNAPHU README and release
notes included with the original source distribution.