What to fix this related libSystem build error

Trying to build a zig project I get this error

zig build             
install
└─ install generated to /Users/finlay/Documents/fun/tigerbeetle/tigerbeetle
   └─ zig build-exe tigerbeetle Debug aarch64-macos 1 errors
error: unable to find libSystem system library
    note: tried /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/libSystem.tbd
    note: tried /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/libSystem.dylib
    note: tried /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/libSystem

and

which zig
/opt/homebrew/bin/zig

The funny thing is that, about last month, I was able to build this progress successfully. So not sure what changed and why I can’t build it anymore.

libSystem.tbd exists in zig 0.13.0 and is located at lib/libc/darwin/libSystem.tbd
but in your installation it searches in .../lib/zig/libc/darwin/libSystem.tbd (note the extra zig between lib and libc).
Perhaps there is a fault in the current homebrew formula.

I stumbled across the same issue after having upgraded to zig 0.13.0 (from 0.11.0). However, the problem wasn’t the wrong path, but that libSystem.tbd was not present in /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/. After finding the following comment https://github.com/ziglang/zig/issues/15963#issuecomment-1585861608, I created a link to the missing file, which fixed the problem for me:

ln -s /Applications/Xcode.app//Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.B.tbd /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/libSystem.tbd

I’m not sure why this is necessary, although the issue has already been closed.

3 Likes

Thanks it worked for me :slight_smile: