# Pb compiling with the 'static' option on Mac OS

**URL:** <https://forum.crystal-lang.org/t/pb-compiling-with-the-static-option-on-mac-os/5334>\
**Category:** Help & Support\
**Created:** [February 6, 2023, 11:38am UTC](https://forum.crystal-lang.org/t/pb-compiling-with-the-static-option-on-mac-os/5334 "2023-02-06T11:38:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [February 6, 2023, 11:38am UTC](https://forum.crystal-lang.org/t/pb-compiling-with-the-static-option-on-mac-os/5334/1 "2023-02-06T11:38:52Z")

</div>

Does it point to a problem with the compiler or to a missing library ?

NB: The same operation works correctly when omitting the ‘static’ option

Alternatively : How do I distribute an app written in Crystal, if it is not statically compiled ?

`otool -L ./bin/hello` yields:

```auto
./bin/hello:
	/opt/homebrew/opt/bdw-gc/lib/libgc.1.dylib (compatibility version 7.0.0, current version 7.1.0)
	/opt/homebrew/opt/libevent/lib/libevent-2.1.7.dylib (compatibility version 8.0.0, current version 8.1.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

```

The problem seems to be related to:

> <https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag>

```auto
crystal build ./src/hello.cr --static --release --progress

```

```auto
ld: library not found for -lcrt0.o **(this usually means you need to install the development package for libcrt0.o)**

clang: error: linker command failed with exit code 1 (use -v to see invocation)

**Error:**  **execution of command failed with code: 1: `cc "${@}" -o /Users/sergehulne/Documents/code/Crystal/0_hello/hello/hello -rdynamic -static -L/opt/homebrew/Cellar/crystal/1.7.2/libexec/../../../../lib -lgc -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent -liconv`**

```

---

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [February 6, 2023, 12:15pm UTC](https://forum.crystal-lang.org/t/pb-compiling-with-the-static-option-on-mac-os/5334/2 "2023-02-06T12:15:41Z")

</div>

If I understand this correctly, I should ship the executable along with libgc.1.dylib and libevent-2.1.7.dylib so that it can be executed on another Mac (using something like: [macos - Why is install\_name\_tool and otool necessary for Mach-O libraries in Mac Os X? - Stack Overflow](https://stackoverflow.com/questions/9263256/why-is-install-name-tool-and-otool-necessary-for-mach-o-libraries-in-mac-os-x)) ?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [February 6, 2023, 1:56pm UTC](https://forum.crystal-lang.org/t/pb-compiling-with-the-static-option-on-mac-os/5334/3 "2023-02-06T13:56:57Z")

</div>

You’re probably running into [Static Linking - Crystal](https://crystal-lang.org/reference/1.7/guides/static_linking.html#macos).
