# Executable wont run on computer without libraries installed

**URL:** <https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408>\
**Category:** Help & Support\
**Created:** [February 11, 2019, 2:04am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408 "2019-02-11T02:04:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iainmon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/iainmon/32/247_2.png) [@Iainmon](https://forum.crystal-lang.org/u/Iainmon)\
**Post date:** [February 11, 2019, 2:04am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/1 "2019-02-11T02:04:29Z")

</div>

This is what I run:

```
crystal build src/test.cr --release --no-debug;

```

When I open it on my machine, it runs fine, but when I open the file on another mac, it says:

```
dyld: Library not loaded: @rpath/libui.A.dylib
Referenced from: /Users/computername/Desktop/test
Reason: image not found
Abort trap: 6

```

I am using this shard ([https://github.com/hedron-crystal/hedron](https://github.com/hedron-crystal/hedron)), and it is basically a way to utilize libui ([https://github.com/andlabs/libui](https://github.com/andlabs/libui)) with crystal. I have zero experience with C and static/dynamic libraries. I always assumed when the crystal program was compiled, it also compiled the C library in with it. Is there any way I can get crystal to build the C library in my /usr/local/lib file in with the compiled crystal executable?

---

<div class="post-metadata">

**Author:** ![vlazar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/vlazar/32/31_2.png) [@vlazar](https://forum.crystal-lang.org/u/vlazar)\
**Post date:** [February 11, 2019, 6:17am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/2 "2019-02-11T06:17:33Z")

</div>

You can build statically linked programs in Crystal but now it only works on Alpine Linux.

You can install Docker for Mac and use [https://hub.docker.com/r/jrei/crystal-alpine](https://hub.docker.com/r/jrei/crystal-alpine) for building statically linked apps.

Basically in addition to Crystal itself you install all required libraries in Docker [https://github.com/j8r/dockerfiles/blob/master/crystal-alpine/Dockerfile#L6-L22](https://github.com/j8r/dockerfiles/blob/master/crystal-alpine/Dockerfile#L6-L22)

Then use `crystal build --static ...` to build statically linked application. After that you can copy your single binary to another Docker container with Alpine Linux but without Crystal and any mentioned libraries installed and it will work.

UPDATE:  
And you’ll also need this workaround [https://github.com/j8r/dockerfiles/tree/master/crystal-alpine#usage](https://github.com/j8r/dockerfiles/tree/master/crystal-alpine#usage)

---

<div class="post-metadata">

**Author:** ![Sija](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/sija/32/737_2.png) [@Sija](https://forum.crystal-lang.org/u/Sija)\
**Post date:** [February 13, 2019, 12:23am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/3 "2019-02-13T00:23:38Z")

</div>

This ain’t work for macOS, unfortunately.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rogerdpack/32/117_2.png) [@rogerdpack](https://forum.crystal-lang.org/u/rogerdpack)\
**Post date:** [February 14, 2019, 3:35am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/4 "2019-02-14T03:35:19Z")

</div>

Can you build “libui” static only and link against that instead?

---

<div class="post-metadata">

**Author:** ![Iainmon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/iainmon/32/247_2.png) [@Iainmon](https://forum.crystal-lang.org/u/Iainmon)\
**Post date:** [February 22, 2019, 5:48am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/5 "2019-02-22T05:48:14Z")

</div>

So does this mean I can install the statically compiled program on any computer even without docker?

---

<div class="post-metadata">

**Author:** ![vlazar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/vlazar/32/31_2.png) [@vlazar](https://forum.crystal-lang.org/u/vlazar)\
**Post date:** [February 22, 2019, 7:04am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/6 "2019-02-22T07:04:55Z")

</div>

You can do it on any computer with Alpine Linux.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [February 22, 2019, 9:54am UTC](https://forum.crystal-lang.org/t/executable-wont-run-on-computer-without-libraries-installed/408/7 "2019-02-22T09:54:28Z")

</div>

A statically linked Linux binary should run on any Linux system, not limited to Alpine.
