binaries produced by zig fail to use SDL
Programs built by zig can't initialize video output (audio is fine, though): SDL_Init(SDL_INIT_VIDEO)
fails.
I wrote a minimal C program to test this further, but I originally noticed the issue when compiling zig code.
to test this, I used the following:
- sdl.c
- zig-logo.bmp
apk add -t .zig zig sdl2 sdl2-dev sdl2_image-dev build-base clang
(using the SDL_image pkg-config to ensure correctness)
> zig cc sdl.c $(pkg-config SDL2_image --cflags --libs) && ./a.out
Could not initialize SDL. SDL_Error: No available video device
Yet the C code is functional:
> gcc sdl.c $(pkg-config SDL2_image --cflags --libs) && ./a.out
# works
and clang (LLVM) also works:
> clang sdl.c $(pkg-config SDL2_image --cflags --libs) && ./a.out
# works
The cause seems to reside at link time:
> zig cc sdl.c $(pkg-config SDL2_image --cflags)
> gcc sdl.o $(pkg-config SDL2_image --libs)
> ./a.out
# works
The issue was already present with Zig 0.5. The same code works with Zig on Debian.
I don't know how to debug this further, but feel free to ask any question.
Edited by Ghost User