# Help with building zig from source (cmake on macOS, with homebrew; trouble linking zstd)

**URL:** <https://ziggit.dev/t/help-with-building-zig-from-source-cmake-on-macos-with-homebrew-trouble-linking-zstd/6381>\
**Category:** Help\
**Tags:** zig-master\
**Created:** [October 15, 2024, 4:18am UTC](https://ziggit.dev/t/help-with-building-zig-from-source-cmake-on-macos-with-homebrew-trouble-linking-zstd/6381 "2024-10-15T04:18:00Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mark-rushakoff](https://ziggit.dev/user_avatar/ziggit.dev/mark-rushakoff/32/3551_2.png) [@mark-rushakoff](https://ziggit.dev/u/mark-rushakoff)\
**Post date:** [October 16, 2024, 3:05am UTC](https://ziggit.dev/t/help-with-building-zig-from-source-cmake-on-macos-with-homebrew-trouble-linking-zstd/6381/5 "2024-10-16T03:05:11Z")

</div>

Thanks @dimdin, this was the missing flag. The vanilla command (using the homebrew-installed llvm, not doing the local checkout of llvm) works when I add only that.

I ran

```shell
$ cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="$(brew --prefix llvm@19);$(brew --prefix lld);$(brew --prefix zstd)" -DZIG_STATIC_ZSTD=ON
$ make -j install/local
# printed several C warnings, then printed many ld warnings like:
# ld: warning: object file (/opt/homebrew/opt/llvm/lib/libclangDriver.a(Action.cpp.o)) was built for newer macOS version (14.0) than being linked (13.3)
# But it completed successfully in about 16 minutes on my 2022 Mac Studio.
$ ./stage3/bin/zig version
0.14.0-dev.1914+1efc9c149

```

> [@mnemnion](#):
>
> I did say in that issue that I was going to do some clean-slate reproductions of the various steps to boil them down to the minimal necessary, and add that information to the wiki. Which I haven’t done. Sorry about that.

I’m going to try and add the ` -DZIG_STATIC_ZSTD=ON` flag to the building from source wiki page, and I’ll backlink to this discussion in the comment. I am pretty sure I had a vanilla initial state aside from a few `brew install` commands.

I think `brew install llvm lld zstd cmake` is sufficient, but I don’t have a fresh system where I can just install homebrew and run that before attempting to build zig from source.

---

_[View the full topic](https://ziggit.dev/t/help-with-building-zig-from-source-cmake-on-macos-with-homebrew-trouble-linking-zstd/6381)._
