zelda3
zelda3 copied to clipboard
Compilation errors
Describe your bug here. And how to reproduce it.
Since commit 3be6ece until most recent 3b7f2a6 the compilation using MSYS is broken.
For windows target the error is:
In file included from third_party/opus-1.3.1-stripped/pitch.h:42,
from third_party/opus-1.3.1-stripped/bands.c:44,
from third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c:11:
third_party/opus-1.3.1-stripped/x86/pitch_sse.h:37:10: fatal error: config.h: No such file or directory
37 | #include "config.h"
| ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:17: third_party/opus-1.3.1-stripped/opus_decoder_amalgam.o] Error 1
make: *** Waiting for unfinished jobs....
for Switch Target the error is:
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:80: /home/Impeeza/zelda3/platform/switch/zelda3.elf] Error 1
make: *** [Makefile:161: bin] Error 2
The packages installed are:
- git
- make
- mingw-w64-x86_64-gcc
- mingw-w64-x86_64-pkgconf
- mingw-w64-x86_64-python-yaml
- mingw-w64-x86_64-python3-pillow
- mingw-w64-x86_64-SDL2
- switch-dev
- switch-sdl2
- switch-tools
going back to commit ec08202 all compile right
Using TCC the file compiles OK.
What is your build target?
Windows
Can you try now?
MinGW64 seems to build fine, but MinGW32 throws some wild new errors:
cc -c -O2 -Werror -IC:/msys64/mingw32/include/SDL2 -Dmain=SDL_main -DSYSTEM_VOLUME_MIXER_AVAILABLE=0 third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c -o third_party/opus-1.3.1-stripped/opus_decoder_amalgam.o
In file included from third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c:24:
third_party/opus-1.3.1-stripped/x86/pitch_sse.c: In function 'dual_inner_prod_sse':
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:86:10: error: SSE vector return without SSE enabled
changes the ABI [-Werror=psabi]
86 | xsum1 = _mm_setzero_ps();
| ~~~~~~^~~~~~~~~~~~~~~~~~
In file included from third_party/opus-1.3.1-stripped/x86/pitch_sse.c:40:
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:118:1: error: inlining failed
in call to 'always_inline' '_mm_setzero_ps': target specific option mismatch
118 | _mm_setzero_ps (void)
| ^~~~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:87:12: note: called from here
87 | xsum2 = _mm_setzero_ps();
| ^~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:118:1: error: inlining failed
in call to 'always_inline' '_mm_setzero_ps': target specific option mismatch
118 | _mm_setzero_ps (void)
| ^~~~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:86:12: note: called from here
86 | xsum1 = _mm_setzero_ps();
| ^~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:184:1: error: inlining failed
in call to 'always_inline' '_mm_add_ps': target specific option mismatch
184 | _mm_add_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:94:15: note: called from here
94 | xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(xi, y2i));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:196:1: error: inlining failed
in call to 'always_inline' '_mm_mul_ps': target specific option mismatch
196 | _mm_mul_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:94:15: note: called from here
94 | xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(xi, y2i));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:184:1: error: inlining failed
in call to 'always_inline' '_mm_add_ps': target specific option mismatch
184 | _mm_add_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:93:15: note: called from here
93 | xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(xi, y1i));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:196:1: error: inlining failed
in call to 'always_inline' '_mm_mul_ps': target specific option mismatch
196 | _mm_mul_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:93:15: note: called from here
93 | xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(xi, y1i));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:932:1: error: inlining failed
in call to 'always_inline' '_mm_loadu_ps': target specific option mismatch
932 | _mm_loadu_ps (float const *__P)
| ^~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:92:20: note: called from here
92 | __m128 y2i = _mm_loadu_ps(y02+i);
| ^~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:932:1: error: inlining failed
in call to 'always_inline' '_mm_loadu_ps': target specific option mismatch
932 | _mm_loadu_ps (float const *__P)
| ^~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:91:20: note: called from here
91 | __m128 y1i = _mm_loadu_ps(y01+i);
| ^~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:932:1: error: inlining failed
in call to 'always_inline' '_mm_loadu_ps': target specific option mismatch
932 | _mm_loadu_ps (float const *__P)
| ^~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:90:19: note: called from here
90 | __m128 xi = _mm_loadu_ps(x+i);
| ^~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:961:1: error: inlining failed
in call to 'always_inline' '_mm_store_ss': target specific option mismatch
961 | _mm_store_ss (float *__P, __m128 __A)
| ^~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:102:4: note: called from here
102 | _mm_store_ss(xy2, xsum2);
| ^~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:128:1: error: inlining failed
in call to 'always_inline' '_mm_add_ss': target specific option mismatch
128 | _mm_add_ss (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:101:12: note: called from here
101 | xsum2 = _mm_add_ss(xsum2, _mm_shuffle_ps(xsum2, xsum2, 0x55));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:744:1: error: inlining failed
in call to 'always_inline' '_mm_shuffle_ps': target specific option mismatch
744 | _mm_shuffle_ps (__m128 __A, __m128 __B, int const __mask)
| ^~~~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:101:12: note: called from here
101 | xsum2 = _mm_add_ss(xsum2, _mm_shuffle_ps(xsum2, xsum2, 0x55));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:184:1: error: inlining failed
in call to 'always_inline' '_mm_add_ps': target specific option mismatch
184 | _mm_add_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:100:12: note: called from here
100 | xsum2 = _mm_add_ps(xsum2, _mm_movehl_ps(xsum2, xsum2));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:785:1: error: inlining failed
in call to 'always_inline' '_mm_movehl_ps': target specific option mismatch
785 | _mm_movehl_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:100:12: note: called from here
100 | xsum2 = _mm_add_ps(xsum2, _mm_movehl_ps(xsum2, xsum2));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:961:1: error: inlining failed
in call to 'always_inline' '_mm_store_ss': target specific option mismatch
961 | _mm_store_ss (float *__P, __m128 __A)
| ^~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:99:4: note: called from here
99 | _mm_store_ss(xy1, xsum1);
| ^~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:128:1: error: inlining failed
in call to 'always_inline' '_mm_add_ss': target specific option mismatch
128 | _mm_add_ss (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:98:12: note: called from here
98 | xsum1 = _mm_add_ss(xsum1, _mm_shuffle_ps(xsum1, xsum1, 0x55));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:744:1: error: inlining failed
in call to 'always_inline' '_mm_shuffle_ps': target specific option mismatch
744 | _mm_shuffle_ps (__m128 __A, __m128 __B, int const __mask)
| ^~~~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:98:12: note: called from here
98 | xsum1 = _mm_add_ss(xsum1, _mm_shuffle_ps(xsum1, xsum1, 0x55));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:184:1: error: inlining failed
in call to 'always_inline' '_mm_add_ps': target specific option mismatch
184 | _mm_add_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:97:12: note: called from here
97 | xsum1 = _mm_add_ps(xsum1, _mm_movehl_ps(xsum1, xsum1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw32/lib/gcc/i686-w64-mingw32/12.2.0/include/xmmintrin.h:785:1: error: inlining failed
in call to 'always_inline' '_mm_movehl_ps': target specific option mismatch
785 | _mm_movehl_ps (__m128 __A, __m128 __B)
| ^~~~~~~~~~~~~
third_party/opus-1.3.1-stripped/x86/pitch_sse.c:97:12: note: called from here
97 | xsum1 = _mm_add_ps(xsum1, _mm_movehl_ps(xsum1, xsum1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors
make: *** [Makefile:17: third_party/opus-1.3.1-stripped/opus_decoder_amalgam.o] Error 1
You could use the system provided packages via pacman -S mingw-w64-x86_64-opus and pacman -S mingw-w64-i686-opus for 64 bit and 32 bit
Hi, for now adding the package pacman -S mingw-w64-i686-opus the Windows target compile well on MSYS
still trying to make work the switch target.
Hi, Windows version compiled with MSYS have a dependency:
but works fine.
The Switch target do not compile the error:
linking zelda3.elf
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find attract.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find ending.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find hud.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find misc.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find overlord.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find player_oam.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find poly.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find select_file.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find spc_player.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find sprite_main.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find tagalong.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find tile_detect.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find apu.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find cart.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find cpu.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find dma.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find dsp.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find input.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find snes.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find snes_other.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find spc.o: No such file or directory
c:/msys64/opt/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/12.1.0/../../../../aarch64-none-elf/bin/ld.exe: cannot find tracing.o: No such file or directory
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:80: /home/Impeeza/zelda3/platform/switch/zelda3.elf] Error 1
make: *** [Makefile:161: bin] Error 2
what I am missing?
Perhaps you can get help in discord?
the commit c08fcb7 compile well for Switch.
The Windows target still have the libwinpthread-1.dll dependency.
Is this still a bug or is it by design in MSYS that it uses the pthread dll?
When I cross compile on Linux with MinGW it does not link in libwinpthread-1.dll, it seems to only do that when using MSYS2. I'm not sure why, since as far as I can tell it is not specified anywhere in the linker command.
After much fighting with MSYS2 and all manner of CFLAGS/LDFLAGS I haven't been able to prevent it from linking libwinpthread-1.dll, or statically link it into the exe without breaking linking with SDL2.dll. I'll continue fighting with it some more this evening.
I think I got it, but it's ugly and I don't particularly like it. Adding the following inbetween the line beginning with LDFLAGS:=... and the line beginning with .PHONY: ... in the Makefile seems to statically link libwinpthread into the exe and prevent libwinpthread-1.dll from being linked as a dependency:
KERNEL_NAME=$(shell uname -s | head -c 5)
ifeq ($(KERNEL_NAME),MINGW)
LDFLAGS:=${LDFLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive
endif
This adds in some additional linker parameters, specifically at the very end of the command, but only if you are building under MSYS2 MinGW32 or MinGW64.
MinGW32 still throws all those "inlining failed" errors that I posted earlier when attempting to compile opus_decoder_amalgam.c, I got around it by linking to the libs provided by mingw-w64-i686-opus and mingw-w64-x86_64-opus in MSYS2, and with the libopus0 and libopus-dev packages in Xubuntu. Here's the patch I came up with for that:
diff --git a/Makefile b/Makefile
index e6db16e..e2f2687 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
TARGET_EXEC:=zelda3
ROM:=tables/zelda3.sfc
-SRCS:=$(wildcard *.c snes/*.c) third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
+SRCS:=$(wildcard *.c snes/*.c) third_party/gl_core/gl_core_3_1.c
OBJS:=$(SRCS:%.c=%.o)
PYTHON:=/usr/bin/env python3
CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror)
@@ -8,6 +8,15 @@ CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror)
CFLAGS:=${CFLAGS} $(shell sdl2-config --cflags) -DSYSTEM_VOLUME_MIXER_AVAILABLE=0
LDFLAGS:=${LDFLAGS} $(shell sdl2-config --libs) -lm
+KERNEL_NAME=$(shell uname -s | head -c 5)
+ifeq ($(KERNEL_NAME),MINGW)
+ LDFLAGS:=${LDFLAGS} -Wl,-Bstatic,--whole-archive -lopus -lwinpthread -Wl,-Bdynamic,--no-whole-archive
+else ifeq ($(KERNEL_NAME),Linux)
+ LDFLAGS:=${LDFLAGS} -lopus
+else
+ SRCS:=${SRCS} third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
+endif
+
.PHONY: all clean clean_obj clean_gen
all: $(TARGET_EXEC) tables/zelda3_assets.dat
It includes what I posted above, but I left out the edit I did to audio.c (changing the opus.h include to #include <opus/opus.h>) as it would break compiling on tcc and msvc unless they were updated to match. I've been working on a build script that creates a zip for opus that's similar to SDL2-devel-2.24.1-VC.zip
Cool, on version 8bee717 compiled using msys target windows still depends on external libwinpthread-1.dll
You're using "MSYS2 MSYS" with the purpleish icon instead of "MSYS2 MinGW 32-bit" with the gray icon or "MSYS2 MinGW 64-bit" with the blue icon?
MSYS2 MinGW64 for Windows 64 bits native binaries on Windows 11
You tried adding those 4 lines I posted earlier into the Makefile and it still requires winpthread?
Ok, I just made 2 compilation sets:
First add
KERNEL_NAME=$(shell uname -s | head -c 5)
ifeq ($(KERNEL_NAME),MINGW)
LDFLAGS:=${LDFLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive
endif
to makefile and generate Zelda3.exe using MINGW64, the resultant executable do not have external dependencies, even doesn't need SDL2.dll
Then create a modified makefile:
New makefile on left, original makefile at right:

and add the package mingw-w64-x86_64-opus, also create a zelda3.exe what need no external dlls.
A side effect is what the new Zelda3.exe have the detail information of libwinpthread-1.dll:

and if you add a .res file to put your own info details the next warning is displayed
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 10 (VERSION) name: 1 lang: 409
but the new Zelda3.exe file have the information on the res file:

make clean && CFLAGS="-DSTBI_NO_THREAD_LOCALS" make
No patch needed. Bug was introduced in 4f62538 when stb_image.h was added, can be fixed by adding #define STBI_NO_THREAD_LOCALS to the top of glsl_shader.c after the line with #define STB_IMAGE_IMPLEMENTATION
The x86 compile errors still are a problem without the patch though, I'll rework it to include the stb_image patch when I get home tonight.
Here's the updated patch that fixes compiling on mingw32 and removes the libwinpthread-1.dll dependency:
diff --git a/Makefile b/Makefile
index e6db16e..72c61bf 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
TARGET_EXEC:=zelda3
ROM:=tables/zelda3.sfc
-SRCS:=$(wildcard *.c snes/*.c) third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
+SRCS:=$(wildcard *.c snes/*.c) third_party/gl_core/gl_core_3_1.c
OBJS:=$(SRCS:%.c=%.o)
PYTHON:=/usr/bin/env python3
CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror)
@@ -8,6 +8,18 @@ CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror)
CFLAGS:=${CFLAGS} $(shell sdl2-config --cflags) -DSYSTEM_VOLUME_MIXER_AVAILABLE=0
LDFLAGS:=${LDFLAGS} $(shell sdl2-config --libs) -lm
+KERNEL_NAME=$(shell uname -s | head -c 5)
+ifeq (${KERNEL_NAME},MINGW)
+ LDFLAGS:=${LDFLAGS} -Wl,-Bstatic -lopus -Wl,-Bdynamic
+else ifdef CROSSCOMPILE
+ CC:=${CROSSCOMPILE}-${CC}
+ LDFLAGS:=${LDFLAGS} -Wl,-Bstatic -lopus -Wl,-Bdynamic
+else ifeq (${KERNEL_NAME},Linux)
+ LDFLAGS:=${LDFLAGS} -lopus
+else
+ SRCS:=${SRCS} third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
+endif
+
.PHONY: all clean clean_obj clean_gen
all: $(TARGET_EXEC) tables/zelda3_assets.dat
diff --git a/glsl_shader.c b/glsl_shader.c
index 8f53d3b..4298bc9 100644
--- a/glsl_shader.c
+++ b/glsl_shader.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <string.h>
#define STB_IMAGE_IMPLEMENTATION
+#define STBI_NO_THREAD_LOCALS
#define STBI_ONLY_PNG
#define STBI_MAX_DIMENSIONS 4096
#define STBI_NO_FAILURE_STRINGS
I left out the one line change to audio.c again, but it will compile fine without that change. I also added something to help with cross compiling (for example: CC="gcc" CROSSCOMPILE="x86_64-w64-mingw32" make)