Cross-compiling -- needs libcrystal.a


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:

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?


I think cross compiling is currently broken because of that libcrystal.a. That library currently results from compiling this file. Ideally we could write that file in Crystal and there wouldn’t be a need for a libcrystal.a.

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


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.


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

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

the command was

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. :/


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).