Open spcutrell opened 3 years ago
It would seem that, on macOS, the default include directories only originate from the output of pkg-config --cflags --libs sdl2
, which is -D_THREAD_SAFE -I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2
.
For me today I get this error:
/Users/hippietrail/sdl-zig-demo/src/main.zig:28:25: error: use of undeclared identifier 'c_void'
@ptrCast(*const c_void, &zig_bmp[0]),
^~~~~~
Which is due to the new change from c_void
to anyopaque
When I change this line
@ptrCast(*const c_void, &zig_bmp[0]),
to
@ptrCast(*const anyopaque, &zig_bmp[0]),
I get the expected
./src/main.zig:1:11: error: C import failed
const c = @cImport({
^
./zig-cache/o/f6a9a2ce854b815a301136d2734c1357/cimport.h:1:10: note: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
But then when I fix
@cInclude("SDL2/SDL.h");
to
@cInclude("SDL.h");
I still get an error:
./src/main.zig:1:11: error: C import failed
const c = @cImport({
^
./zig-cache/o/b7cf683efbb6bf33a94d96128858c0f8/cimport.h:1:10: note: 'SDL.h' file not found
#include <SDL.h>
@spcutrell maybe the sdl2 on your Mac is not linked properly. This is what I did to resolve this:
❯ brew install sdl2
Warning: sdl2 2.28.5 is already installed, it's just not linked.
To link this version, run:
brew link sdl2
Then
❯ brew link sdl2
Linking /usr/local/Cellar/sdl2/2.28.5...
Error: Could not symlink bin/sdl2-config
Target /usr/local/bin/sdl2-config
already exists. You may want to remove it:
rm '/usr/local/bin/sdl2-config'
To force the link and overwrite all conflicting files:
brew link --overwrite sdl2
❯ brew link --overwrite sdl2 Linking /usr/local/Cellar/sdl2/2.28.5... 87 symlinks created. ❯ zig build run
Issue: Does not build on Mac.
Error:
Fix: Change "SDL/SDL2" to "SDL2" in cImport.
Example of fix: