msys2 / MSYS2-packages

Package scripts for MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
1.28k stars 483 forks source link

Build dvtm + abduco for MSYS2 on Win 11 #3307

Open sukerat opened 1 year ago

sukerat commented 1 year ago

I have been trying to build dvtm from source but I get the below output when running make after adding "-D_WCTYPE_T" to the build options to get past a prior error.

Any Ideas for me on how to get this to build for MSYS2?


dvtm build options:

CFLAGS   = -std=c99 -I. -I/usr/include -DVERSION="0.15" -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED -D_WCTYPE_T
LDFLAGS  = -lc -lutil -lncursesw
CC       = cc
CC dvtm.c
In file included from C:/msys64/usr/include/sys/fcntl.h:3,
                 from C:/msys64/usr/include/fcntl.h:12,
                 from dvtm.c:24:
C:/msys64/usr/include/sys/_default_fcntl.h:186:8: error: redefinition of 'struct flock'
  186 | struct flock {
      |        ^~~~~
In file included from C:/msys64/usr/include/sys/types.h:224,
                 from C:/msys64/usr/include/sys/unistd.h:12,
                 from C:/msys64/usr/include/unistd.h:4,
                 from dvtm.c:14:
C:/msys64/usr/include/machine/types.h:46:8: note: originally defined here
   46 | struct flock {
      |        ^~~~~
In file included from C:/msys64/usr/include/errno.h:9,
                 from dvtm.c:33:
C:/msys64/usr/include/sys/errno.h:14: warning: "errno" redefined
   14 | #define errno (*__errno())
      |
In file included from C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/stddef.h:1,
                 from C:/msys64/usr/include/stdlib.h:16,
                 from dvtm.c:13:
C:/msys64/mingw64/include/stddef.h:19: note: this is the location of the previous definition
   19 | #define errno (*_errno())
      |
make: *** [Makefile:19: dvtm.o] Error 1

I have dragged and dropped a screenshot of the output as a prettier output of the problem.

mmuetzel commented 1 year ago

Don't mix headers from MINGW and MSYS2. Either remove -I/usr/include or build in an MSYS2 shell.

sukerat commented 1 year ago

I am building in an MSYS2 shell: C:\msys64\ucrt64.exe I have also tried others with the exact same outcome.

When I remove the -I/usr/include from config.mk, I get issues with headers that are missing:


$ make
cleaning
dvtm build options:
CFLAGS   = -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED -D_WCTYPE_T
LDFLAGS  = -lc -lutil -lncursesw
CC       = gcc
CC dvtm.c
dvtm.c:18:10: fatal error: sys/select.h: No such file or directory
   18 | #include <sys/select.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:19: dvtm.o] Error 1

mmuetzel commented 1 year ago

Sorry I wasn't clearer before. I meant the "real" MSYS2 shell (the magenta icon).

The header sys/select.h is POSIX-specific. If the software relies on including it, that means that it isn't compatible to the (native) Windows platform. The MSYS2 environment is kind of like a "POSIX on Windows" build environment. It is incompatible to native build environments in that it is not possible to mix headers or load libraries from one environment in executables from the other environment.

IIUC, dwm is a "standalone application" (not a library). So, you might have a chance of building a useful application in the MSYS2 environment (i.e., using the shell with the magenta icon).