Skip to content

Conversation

@Riadabd
Copy link

@Riadabd Riadabd commented Jan 3, 2026

Toolchain

> zig version
0.15.2

Issue

On a clean checkout on macOS, zig build fails because the resid_mixer dependency can’t find SDL2 headers during @cImport. Raw error log:

  install
  └─ install 1st-shot
  └─ compile exe 1st-shot ReleaseFast native 2 errors
  ~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/resid-mixer.zig:3:13: error: C import failed
  const SDL = @cImport({
  ^~~~~~~~
  referenced by:
  update: ~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/resid-mixer.zig:124:21
  playerThreadFunc: src/SoundManager.zig:34:27
  11 reference(s) hidden; use '-freference-trace=13' to see all references
  .zig-cache/o/b579a38a593cb21a8da784ef79e7487e/cimport.h:1:10: error: 'SDL2/SDL.h' file not found
  #include <SDL2/SDL.h>
  ^
  error: the following command failed with 2 compilation errors:
  /opt/homebrew/Cellar/zig/0.15.2/bin/zig build-exe -I/opt/homebrew/include -I/opt/homebrew/include/SDL2 -D_THREAD_SAFE -L/opt/homebrew/lib -lSDL2 -OReleaseFast -I ~/Code/zig/1st-shot/src/core/
  lodepng/ --dep movy --dep resid -Mroot=~/Code/zig/1st-shot/src/main.zig ~/.cache/zig/p/movy-0.0.4-UtRV6xTmCwBXPu130iqjXTGTuzlPjBOcT7S2SmF_pdvw/src/core/lodepng/lodepng.c -OReleaseFast -I ~/.cache/zig/p/movy-0.0.4-UtRV6xTmCwBXPu130iqjXTGTuzlPjBOcT7S2SmF_pdvw/src/core/lodepng/ -Mmovy=~/.cache/zig/p/movy-0.0.4-UtRV6xTmCwBXPu130iqjXTGTuzlPjBOcT7S2SmF_pdvw/src/movy.zig .zig-
  cache/o/0b634b7227692218aaf4542f806f7311/libsid.a -I ~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/resid-cpp -I .zig-cache/i/83345b95a32f5a3bfba2443f68782617/include/resid-
  cpp -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 --dep sidfile --dep wavwriter --dep wavloader --dep resid_cpp --dep resid_sdl --dep resid_mixer --dep sidplayer --dep zig64 -Mresid=~/.cache/zig/
  p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/resid.zig -Msidfile=~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/sidfile.zig -Mwavwriter=~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/wavwriter.zig -Mwavloader=~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/
  wavloader.zig .zig-cache/o/0b634b7227692218aaf4542f806f7311/libsid.a -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -I ~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/
  resid-cpp -I .zig-cache/i/83345b95a32f5a3bfba2443f68782617/include/resid-cpp -Mresid_cpp=~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/resid-cpp.zig -I resid-cpp/ -I /
  usr/include/ --dep resid_cpp -Mresid_sdl=~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/resid-sdl.zig -I /usr/include/ --dep resid_cpp -Mresid_mixer=~/.cache/
  zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/resid-mixer.zig --dep sidfile --dep zig64 -Msidplayer=~/.cache/zig/p/resid-0.5.0-CVhkLsp0CwDSJejbTOub4ir4sj1q4-yMLAr_7TcALvZV/src/
  sidplayer.zig -Mzig64=~/.cache/zig/p/zig64-0.5.0-OrrYOvgZBACGKIsII5d6w596RqNmpCCJkAeQxfCsKsQW/src/zig64.zig -lc++ -lc --cache-dir .zig-cache --global-cache-dir ~/.cache/zig --name 1st-shot
  --zig-lib-dir /opt/homebrew/Cellar/zig/0.15.2/lib/zig/ --listen=-

  Build Summary: 4/7 steps succeeded; 1 failed
  install transitive failure
  └─ install 1st-shot transitive failure
  └─ compile exe 1st-shot ReleaseFast native 2 errors

  error: the following build command failed with exit code 1:
  .zig-cache/o/41438c16014b11875c927058dc3ea791/build /opt/homebrew/Cellar/zig/0.15.2/bin/zig /opt/homebrew/Cellar/zig/0.15.2/lib/zig ~/Code/zig/1st-shot .zig-cache ~/.cache/zig --seed
  0x8b232f1a -Z573023f54c52820c

Fix

  • Add macOS-only SDL2 prefix handling in build.zig.
  • Add SDL2 include/library paths to resid_mixer (for @cImport) and to the main executable (for linking).
  • Support override via -Dsdl2-prefix=..., defaulting to the SDL2 Homebrew path (/opt/homebrew/opt/sdl2).

Add macOS-only SDL2 include/library path wiring for the resid_mixer
dependency and the main executable. This fixes SDL2/SDL.h not found
during `@cImport` on clean macOS builds. Includes a `-Dsdl2-prefix`
override with a Homebrew default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant