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.

5 Likes

Thanks it worked for me :slight_smile:

1 Like

In case you have just the Developer Tools, you can use
ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/lib/libSystem.tbd /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/libSystem.tbd

Change the path depending what macOS are you running.

I couldn’t figure out why the libSystem isn’t included and FYI, I don’t know the difference between .../usr/lib/libSystem.B.tbd and .../usr/lib/libSystem.tbd

Opened an issue for tracking this at homebrew: zig formula is missing file libSystem.tbd · Issue #209483 · Homebrew/homebrew-core · GitHub

After copying libSystem.tbd and building my project everything is fine.

1 Like