"win_main.h: No such file or directory" when compiling for Windows #202

Closed
opened 2025-09-25 01:28:54 +02:00 by undergroundmonorail · 5 comments
undergroundmonorail commented 2025-09-25 01:28:54 +02:00 (Migrated from github.com)

I've attempted to compile for Windows using the instructions on the SRB2 wiki, both inside the WSL and via MSYS2, and I have the same problem in both. Here's the entire output of my compilation attempt:

Attempt 1 output
$ make clean && MINGW64=1 make -j 4
make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src'
Detected a Windows system, compiling for 64-bit MinGW SDL2...
make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src'
make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src'
Creating dependency file, depend.dep
win32/win_dbg.c:24:10: fatal error: win_main.h: No such file or directory
   24 | #include "win_main.h"
      |          ^~~~~~~~~~~~
compilation terminated.
../comptime.sh .
d_netfil.c:114:8: error: unknown type name 'I_mutex'
  114 | static I_mutex downloadmutex;
      |        ^~~~~~~
d_netfil.c: In function 'CURLAbortFile':
d_netfil.c:1367:9: error: implicit declaration of function 'I_lock_mutex' [-Wimplicit-function-decla
ration]
 1367 |         I_lock_mutex(&downloadmutex);
      |         ^~~~~~~~~~~~
d_netfil.c:1367:9: warning: nested extern declaration of 'I_lock_mutex' [-Wnested-externs]
d_netfil.c:1368:9: error: implicit declaration of function 'I_unlock_mutex'; did you mean '_unlock_f
ile'? [-Wimplicit-function-declaration]
 1368 |         I_unlock_mutex(downloadmutex);
      |         ^~~~~~~~~~~~~~
      |         _unlock_file
d_netfil.c:1368:9: warning: nested extern declaration of 'I_unlock_mutex' [-Wnested-externs]
make[1]: *** [Makefile:752: ../objs/Mingw64/Release/d_netfil.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src'
make: *** [Makefile:8: all] Error 2
I looked for `win_main.h` and found that it was deleted in commit 2ce980325 from a couple years ago, so I'm not sure what exactly I'm doing wrong.

Just in case, I also tried without the MINGW64=1 flag (it was unclear to me if it was necessary) and got this output:

Attempt 2 output
$ make clean && make -j 4
make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src'
Detected a Windows system, compiling for 64-bit MinGW SDL2...
Creating dependency file, depend.dep
Created dependency file, depend.dep
Detected a Windows system, compiling for 64-bit MinGW SDL2...
make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src'
make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src'
Detected a Windows system, compiling for 64-bit MinGW SDL2...
Creating dependency file, depend.dep
Created dependency file, depend.dep
Detected a Windows system, compiling for 64-bit MinGW SDL2...
..\comptime.bat .
Linking srb2kart-saturn.exe...
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(png.c.obj):png.c:(.text+0x516): undefined reference to `_setjmp'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xdf4): undefined reference to `_setjmp'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xea2): undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xec1): undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xf5c): undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xf7f): undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0x11a1): undefined reference to `_setjmp'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:630: ../bin/Mingw64/Release/srb2kart-saturn.exe] Error 1
make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src'
make: *** [Makefile:8: all] Error 2

Either way, compilation for Windows fails. Is there another process that's supposed to be used?

I've attempted to compile for Windows using the instructions on the SRB2 wiki, both inside the WSL and via MSYS2, and I have the same problem in both. Here's the entire output of my compilation attempt: <details><summary>Attempt 1 output</summary> <pre> $ make clean && MINGW64=1 make -j 4 make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src' Detected a Windows system, compiling for 64-bit MinGW SDL2... make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src' make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src' Creating dependency file, depend.dep win32/win_dbg.c:24:10: fatal error: win_main.h: No such file or directory 24 | #include "win_main.h" | ^~~~~~~~~~~~ compilation terminated. ../comptime.sh . d_netfil.c:114:8: error: unknown type name 'I_mutex' 114 | static I_mutex downloadmutex; | ^~~~~~~ d_netfil.c: In function 'CURLAbortFile': d_netfil.c:1367:9: error: implicit declaration of function 'I_lock_mutex' [-Wimplicit-function-decla ration] 1367 | I_lock_mutex(&downloadmutex); | ^~~~~~~~~~~~ d_netfil.c:1367:9: warning: nested extern declaration of 'I_lock_mutex' [-Wnested-externs] d_netfil.c:1368:9: error: implicit declaration of function 'I_unlock_mutex'; did you mean '_unlock_f ile'? [-Wimplicit-function-declaration] 1368 | I_unlock_mutex(downloadmutex); | ^~~~~~~~~~~~~~ | _unlock_file d_netfil.c:1368:9: warning: nested extern declaration of 'I_unlock_mutex' [-Wnested-externs] make[1]: *** [Makefile:752: ../objs/Mingw64/Release/d_netfil.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src' make: *** [Makefile:8: all] Error 2 </pre> </details> I looked for `win_main.h` and found that it was deleted in commit 2ce980325 from a couple years ago, so I'm not sure what exactly I'm doing wrong. Just in case, I also tried without the `MINGW64=1` flag (it was unclear to me if it was necessary) and got this output: <details><summary>Attempt 2 output</summary> <pre> $ make clean && make -j 4 make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src' Detected a Windows system, compiling for 64-bit MinGW SDL2... Creating dependency file, depend.dep Created dependency file, depend.dep Detected a Windows system, compiling for 64-bit MinGW SDL2... make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src' make[1]: Entering directory '/d/Documents/SRB2Kart-Saturn/src' Detected a Windows system, compiling for 64-bit MinGW SDL2... Creating dependency file, depend.dep Created dependency file, depend.dep Detected a Windows system, compiling for 64-bit MinGW SDL2... ..\comptime.bat . Linking srb2kart-saturn.exe... C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(png.c.obj):png.c:(.text+0x516): undefined reference to `_setjmp' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xdf4): undefined reference to `_setjmp' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xea2): undefined reference to `__imp___iob_func' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xec1): undefined reference to `__imp___iob_func' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xf5c): undefined reference to `__imp___iob_func' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0xf7f): undefined reference to `__imp___iob_func' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../libs/libpng-src/projects/libpng64.a(pngerror.c.obj):pngerror.c:(.text+0x11a1): undefined reference to `_setjmp' collect2.exe: error: ld returned 1 exit status make[1]: *** [Makefile:630: ../bin/Mingw64/Release/srb2kart-saturn.exe] Error 1 make[1]: Leaving directory '/d/Documents/SRB2Kart-Saturn/src' make: *** [Makefile:8: all] Error 2 </pre> </details> Either way, compilation for Windows fails. Is there another process that's supposed to be used?
alufolie91 commented 2025-09-25 02:09:15 +02:00 (Migrated from github.com)

Not entirely sure why, but it appears that some compiler and linker flags get omitted (it tries to build without sdl2).
Could you try running make clean and make -j 4 separately?

Not entirely sure why, but it appears that some compiler and linker flags get omitted (it tries to build without sdl2). Could you try running `make clean` and `make -j 4` separately?
undergroundmonorail commented 2025-09-25 02:37:06 +02:00 (Migrated from github.com)

Unfortunately, I'm a fool, and I looked directly past the bold "close the MSYS2 window and open mingw32.exe" instruction on the page. Oops, sorry. Having actually followed the instructions, I was able to get it to build without MINGW64=1 (I get same error if I do include the flag).

However, when I try to launch it, I get error messages complaining about missing libcurl.dll, exchndl.dll, discord-rpc.dll, and libgme.dll. I can find the third and fourth in the libs/dll-binaries/x86_64/ directory, but is there something different I have to do to get the other two?

Unfortunately, I'm a fool, and I looked directly past the bold "**close the MSYS2 window and open mingw32.exe**" instruction on the page. Oops, sorry. Having actually followed the instructions, I was able to get it to build without `MINGW64=1` (I get same error if I do include the flag). However, when I try to launch it, I get error messages complaining about missing libcurl.dll, exchndl.dll, discord-rpc.dll, and libgme.dll. I can find the third and fourth in the `libs/dll-binaries/x86_64/` directory, but is there something different I have to do to get the other two?
alufolie91 commented 2025-09-25 02:45:58 +02:00 (Migrated from github.com)

using mingw32 will build a 32bit executable, so the correct dlls would be in libs/dll-binaries/i686/
alternatively they are included in the release zips from https://github.com/Indev450/SRB2Kart-Saturn/releases/tag/v8.3 or with a vanilla kart install

using mingw32 will build a 32bit executable, so the correct dlls would be in libs/dll-binaries/i686/ alternatively they are included in the release zips from https://github.com/Indev450/SRB2Kart-Saturn/releases/tag/v8.3 or with a vanilla kart install
undergroundmonorail commented 2025-09-25 22:52:27 +02:00 (Migrated from github.com)

Yep, that works! I also I think I just independently figured out the same thing you put into the readme file 10 minutes ago, that I could use the 64-bit msys2 executable and replace the architecture with x86_64 in the package name to get the 64 bit build to work. I was just coming here to say that I had managed it when I saw the new commit, haha

Thank you for taking a look :3

Yep, that works! I also I think I just independently figured out the same thing you put into the readme file 10 minutes ago, that I could use the 64-bit msys2 executable and replace the architecture with `x86_64` in the package name to get the 64 bit build to work. I was just coming here to say that I had managed it when I saw the new commit, haha Thank you for taking a look :3
alufolie91 commented 2025-09-25 22:59:32 +02:00 (Migrated from github.com)

Sure thing!
glad it helped and everything worked now c:

figured it could use some better explaining since the linked instructions weren't particularly clear about it (srb2 does not "support" 64bit windows builds after all)

Sure thing! glad it helped and everything worked now c: figured it could use some better explaining since the linked instructions weren't particularly clear about it (srb2 does not "support" 64bit windows builds after all)
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: saturn/SRB2Kart-Saturn#202