Skip to content

Compile fails on MSYS/MINGW64 with missing curses.h #84

@eabase

Description

@eabase

Running the compile line in README fails by missing curses.h file.

# ./autogen.sh && ./configure && make

...
config.status: creating config.h
gcc -DHAVE_CONFIG_H -g -O2  -c hexedit.c
In file included from hexedit.c:17:
hexedit.h:16:10: fatal error: curses.h: No such file or directory
   16 | #include <curses.h>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:31: hexedit.o] Error 1

But I already have curses.h:

# find /c/msys64/mingw64/ -iname "curses.h"

/c/msys64/mingw64/include/ncurses/curses.h
/c/msys64/mingw64/include/ncursesw/curses.h

Activity

eabase

eabase commented on Oct 18, 2025

@eabase
Author

I managed to get original hexedit to compile under MSYS, but not under MINGW64, without minor patching. See raised MinGW64 package request.

Some AI told me:

The error storage size of 'sa' isn't known means that struct sigaction is not defined. 
This is a POSIX-specific structure that doesn't exist in Windows/MinGW's headers.
This is a deeper compatibility issue - hexedit uses POSIX signal handling which isn't directly available on Windows.

So I tried on MSYS, and it worked.

I also managed to get it to compile and run for MINGW64.
But you need to apply the following patches, created by git diff display.c interact.c:

diff --git a/display.c b/display.c
index 06a2b31..7812f30 100644
--- a/display.c
+++ b/display.c
@@ -14,6 +14,10 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
+#include <windows.h>
+#ifndef __MINGW32__
+#include <signal.h>
+#endif
 #include "hexedit.h"

 int move_cursor(INT delta)
@@ -103,7 +107,9 @@ int computeCursorXPos(int cursor, int hexOrAscii)

 void initCurses(void)
 {
+#ifndef __MINGW32__
   struct sigaction sa;
+#endif
   initscr();

 #ifdef HAVE_COLORS
diff --git a/interact.c b/interact.c
index 5eb1fc4..0668375 100644
--- a/interact.c
+++ b/interact.c
@@ -15,7 +15,11 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
 #include "hexedit.h"
-
+#ifndef __MINGW32__
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#endif

 static void goto_char(void);
 static void goto_sector(void);
@@ -116,7 +120,14 @@ static void end_of_buffer(void)
   set_cursor(s);
 }

+#ifdef __MINGW32__
+static void suspend(void) {
+  displayMessageAndWaitForKey("Suspend not supported on Windows");
+}
+#else
 static void suspend(void) { kill(getpid(), SIGTSTP); }
+#endif
+
 static void undo(void) { discardEdited(); readFile(); }
 static void quoted_insert(void) { setTo(getch()); }
 static void toggle(void) { hexOrAscii = (hexOrAscii + 1) % 2; }
@@ -306,6 +317,15 @@ static void save_buffer(void)

 static void help(void)
 {
+#ifdef __MINGW32__
+  /* Windows doesn't have fork/exec, and likely doesn't have man pages */
+  displayTwoLineMessage(
+    "Help: Open https://github.com/pixel/hexedit in a browser",
+    "or run 'man hexedit' on Linux/Unix for full documentation"
+  );
+  getch();
+  refresh();
+#else
   char *args[3];
   int status;

@@ -319,6 +339,7 @@ static void help(void)
   }
   wait(&status);
   refresh();
+#endif
   raw();
 }

However, the --color switch produces no color in MINGW64.
Also, the binaries are not compatible, and need to be compiled for each environment.
(I'm not sure how to make them environment agnostic.)

eabase

eabase commented on Oct 18, 2025

@eabase
Author

The build commands for MSYS and MINGW64 are:

# For MSYS:
./autogen.sh && ./configure CFLAGS="-I/usr/include/ncursesw" LDFLAGS="-L/usr/lib" LIBS="-lncursesw" && make

# For MINGW64:
./autogen.sh && ./configure CFLAGS="-I/mingw64/include/ncursesw" LDFLAGS="-L/mingw64/lib" LIBS="-lncursesw" && make
prigaux

prigaux commented on Oct 18, 2025

@prigaux
Collaborator

I have pushed two cleanup commits that should help, can you try?

chore: remove unused include (should help build on MINGW64)

chore: remove leftover from commit "Move SIGWINCH handling from handler to NCURSES"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @prigaux@eabase

        Issue actions