# Cross-compiling -- needs libcrystal.a

**URL:** https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457
**Category:** Help & Support
**Created:** [February 22, 2019, 12:08am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457 "2019-02-22T00:08:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![scott](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/scott/32/948_2.png) [@scott](https://forum.crystal-lang.org/u/scott)
#### Post date: [February 22, 2019, 12:08am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457/1 "2019-02-22T00:08:54Z")

</div>

I’m trying to cross-compile an application to ARMv6 (original raspberry pi). If I run the command output by `crystal build` on the Pi, I get the following error:

```auto
cc: error: /usr/share/crystal/src/ext/libcrystal.a: No such file or directory

```

How do I get a `libcrystal.a` for a target platform which doesn’t have a compiled Crystal?

---

<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, 12:33am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457/2 "2019-02-22T00:33:44Z")

</div>

I think cross compiling is currently broken because of that `libcrystal.a`. That library currently results from compiling [this file](https://github.com/crystal-lang/crystal/blob/master/src/ext/sigfault.c). [Ideally we could write that file in Crystal](https://github.com/crystal-lang/crystal/issues/3839) and there wouldn’t be a need for a `libcrystal.a`.

I’m not sure Crystal will work on a raspberry pi.

---

<div class="post-metadata">

### Author: ![scott](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/scott/32/948_2.png) [@scott](https://forum.crystal-lang.org/u/scott)
#### Post date: [February 22, 2019, 12:46am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457/3 "2019-02-22T00:46:53Z")

</div>

Well, I definitely don’t think the Pi itself would be able to compile crystal, but I don’t see any reason cross-compiled binaries wouldn’t work. Thanks for the helpful links, I’ll look into it some more in a bit.

---

<div class="post-metadata">

### Author: ![scott](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/scott/32/948_2.png) [@scott](https://forum.crystal-lang.org/u/scott)
#### Post date: [February 22, 2019, 1:20am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457/4 "2019-02-22T01:20:26Z")

</div>

Well… I got all the linked binaries installed, compiled sigfault.c as libcrystal.a, and ran the command…which gave me this error:

```auto
flix.arm.o: In function `__crystal_main':
/usr/share/crystal/src/kernel.cr:543: undefined reference to `setup_sigfault_handler'
flix.arm.o: In function `crypto_scrypt':
/home/scott/Documents/code/flix/lib/scrypt/src/engine.cr:38: undefined reference to `crypto_scrypt'
collect2: error: ld returned 1 exit status

```

the command was

```auto
cc 'flix.arm.o' -o 'flix.arm' -rdynamic -L/home/scott/Documents/code/flix/lib/scrypt/src/../ext -lscrypt -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lyaml -lmagic -lpcre -lm -lgc -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib

```

I’m just documenting what happened, I’ll do some more research on this a little while later. :/

---

<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:52am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457/5 "2019-02-22T09:52:22Z")

</div>

For completeness, on the cross-compiling target platform, you need to check out the Crystal repo and run `make libcrystal` in order to build `libcrystal.a`.  
(Actually, you don’t need the entire repo, `Makefile` and `src/ext` folder should be enough).

---

<div class="post-metadata">

### Author: ![scott](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/scott/32/948_2.png) [@scott](https://forum.crystal-lang.org/u/scott)
#### Post date: [February 24, 2019, 12:36am UTC](https://forum.crystal-lang.org/t/cross-compiling-needs-libcrystal-a/457/6 "2019-02-24T00:36:20Z")

</div>

thanks!
