# Run executable on another computer without crystal installed?

**URL:** <https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448>\
**Category:** Help & Support\
**Created:** [February 21, 2019, 5:25am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448 "2019-02-21T05:25:00Z")\
**Posts on this page:** 8\
**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 21, 2019, 5:25am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/1 "2019-02-21T05:25:00Z")

</div>

I have built a simple User Agent for macOS, and it runs perfectly on my machine, but when I try to install it on anyone else’s machine, I get the following error:

```
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/USERNAME/Desktop/binary
Reason: image not found
Trace/BPT trap: 5

```

I am only using crystal’s standard API. I am not using anything that requires SSL, I am only making an HTTP request, not HTTPS.

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [February 21, 2019, 10:52am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/2 "2019-02-21T10:52:31Z")

</div>

In this particular case you can compile your program with `-D without_openssl`. However I can’t guarantee that will work forever. And in general, you need the target machine to have more or less the same libraries as the machine you compile your program in.

---

<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 21, 2019, 1:16pm UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/3 "2019-02-21T13:16:39Z")

</div>

> [@asterite](#):
>
> And in general, you need the target machine to have more or less the same libraries as the machine you compile your program in.

More general: The target machine needs to have the libraries available which the binary was linked with.

---

<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, 7:06am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/4 "2019-02-22T07:06:31Z")

</div>

Thanks for your reply. I just tested it, and it is giving a different error. Even why I try `crystal build src/app.cr --static -D without_openssl without_libgc`

```
dyld: Library not loaded: /usr/local/opt/bdw-gc/lib/libgc.1.dylib
Referenced from: /Volumes/DRIVE/binary
Reason: image not found
Trace/BPT trap: 5
```

---

<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, 10:00am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/5 "2019-02-22T10:00:48Z")

</div>

I don’t think `without_libgc` is a valid compiler flag. There is `gc_none` which is probably what you mean. But it’s probably not a good idea to compile without GC because it will eventually break you program. The stdlib expects a working GC.

The solution is probably to install the proper bwdgc library on your system.

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [February 22, 2019, 10:53am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/6 "2019-02-22T10:53:24Z")

</div>

That we have `without_openssl` doesn’t mean you can exclude any library. Only that flag, and one to exclude `zlib` exist. The reason is the compiler includes an HTTP::Server and distributing that with openssl and zlib is a bit hard so we compile it without those things. It’s a hack. Eventually those flags will disappear and the HTTP::Server won’t be needed in the compiler as the playground will be extracted to a different binary.

---

<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 23, 2019, 3:24am UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/7 "2019-02-23T03:24:41Z")

</div>

Is there a way I can use relative paths, and create a folder for the compiled crystal program to run in along with the libraries? My goal is to be able to install this on a brand new mac, without any command line installation of libraries or the crystal language.

---

<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 26, 2019, 11:22pm UTC](https://forum.crystal-lang.org/t/run-executable-on-another-computer-without-crystal-installed/448/8 "2019-02-26T23:22:48Z")

</div>

You should be able to ship dynamic libraries with your binary and use `LD_LIBRARY_PATH` to add their location to the paths that are looked up for finding dynamic libraries. I’m not sure if there are any specific caveats on MacOS.

However, as far as I understand the static linking problem on MacOS, the issue are actually system libraries which are only available as dynamic libraries. So you can’t link a _fully_ dynamic binary. But you _can_ build static libraries. And as long as you have those `.a` files available, you can link them into your binary. This seems to need some trickery if a dynamic variant of the same library is also available, but it’s manageable. See [https://github.com/crystal-lang/crystal/issues/2003#issuecomment-170331227](https://github.com/crystal-lang/crystal/issues/2003#issuecomment-170331227) and following comments for some more details on this.

So you _should_ be able to build a binary that has all custom libraries statically linked.
