如何在树莓派上安装 crystal-lang?

How do I install crystal-lang on rapsberry pi?

当我尝试按照 debian install instructions 将其添加到源时,出现此错误。我猜这意味着它没有 arm 包。

Failed to fetch https://dist.crystal-lang.org/apt/dists/crystal/InRelease Unable to find expected entry 'main/binary-armhf/Packages' in Release file (Wrong sources.list entry or malformed file)

我猜我可能需要从源代码安装它。我将如何用一只手臂 cpu 来做到这一点?当我检查它并 运行 make 我得到错误:

You need to have a crystal executable in your path! Makefile:113: recipe for target '.build/crystal' failed make: *** [.build/crystal] Error 1

如有任何建议,我们将不胜感激。

编辑:raspbian 上现在有一个 crystal 的半官方存储库,请在此处查看:http://public.portalier.com/raspbian


Crystal 不会为 ARM 构建 Debian 软件包,您是正确的,因为您需要从源代码构建。

然而,Crystal编译器是用Crystal编写的。这提出了一个明显的问题,即如何让编译器构建编译器。答案是交叉编译:在x86台式电脑上构建一个arm二进制文件,然后跨过来复制。

根据我上次交叉编译的记忆,这是一个快速的逐步步骤:

  1. 在 x86 桌面 PC 上安装 Crystal,并检查它是否正常工作。
  2. 安装 all required libraries on the desktop and Raspberry Pi. You'll need the same LLVM version on the Raspberry Pi and desktop. This is probably the hardest and longest step. You can install llvm 3.9 from debian testing for ARM, see this Whosebug post 了解如何从 debian 测试中仅安装 LLVM。
  3. 在两台计算机上查看来自 git 的来源,以及 运行 make deps
  4. 通过 运行 在 git 存储库的根目录中执行此命令来交叉编译编译器:
    ./bin/crystal build src/compiler/crystal.cr --cross-compile --target arm-unknown-linux-gnueabihf --release -s -D without_openssl -D without_zlib</pre>
    此命令将在您的当前目录中创建一个 crystal.o 文件,并输出一个链接器命令 (cc crystal.o -o crystal ...).
  5. 复制crystal.o到raspberry pi和运行链接器命令。请务必编辑 llvm_ext.o 的绝对路径,使其指向 Raspberry Pi 上的 Crystal 结帐,而不是桌面上的结帐。还要确保命令中对 llvm-config 的所有引用都针对正确的 LLVM 版本。例如,在 Raspbian.
  6. 上将 /usr/local/bin/llvm-config 更改为 llvm-config-3.9
  7. 运行 当前目录 (./crystal -v) 中的 crystal 可执行文件并确保它可以正常工作。
  8. 确保将 CRYSTAL_PATH 环境变量设置为 lib:/path/to/crystal/source/checkout/src 以便编译器在编译应用程序时可以找到标准库。