Ubuntu/Linux/Windows/macOS 下安装 Crystal

Crystal语言是运行在本地环境的编译型、强类型语言,运行不需要类似虚拟机之类的中间层,编译时在底层使用LLVM进行优化。 有一定的类型推断能力,在堆码的过程中不一定需要显示的指定数据类型。自动GC。

Debian/Ubuntu

Debian分支的Linux可以使用官方的仓库来安装

先添加源

curl https://dist.crystal-lang.org/apt/setup.sh | sudo bash

然后

apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54
echo "deb https://dist.crystal-lang.org/apt crystal main" > /etc/apt/sources.list.d/crystal.list
apt-get update

安装

sudo apt-get install crystal

更新

有新的版本发布时,使用如下命令更新

sudo apt-get update
sudo apt-get install crystal

RedHat/Linux

可以使用官方的仓库安装

添加源

curl https://dist.crystal-lang.org/rpm/setup.sh | sudo bash
rpm --import https://dist.crystal-lang.org/rpm/RPM-GPG-KEY

cat > /etc/yum.repos.d/crystal.repo <<END
[crystal]
name = Crystal
baseurl = https://dist.crystal-lang.org/rpm/
END

安装

sudo yum install crystal

更新

有新的版本发布时可以执行

sudo yum update crystal

ArchLinux

社区的仓库中已经包含了Crystal的编译器

安装

sudo pacman -S crystal

Gentoo

Gentoo的版本仓库已经包含了Crystal的编译器

配置

你可以先查看一下设置,运行

# equery u dev-lang/crystal
[ Legend : U - final flag setting for installation]
[ : I - package is installed with flag ]
[ Colors : set, unset ]
* Found these USE flags for dev-lang/crystal-0.18.7:
U I
- - doc : Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
- - examples : Install examples, usually source code
+ + xml : Use the dev-libs/libxml2 library to enable Crystal xml module
+ - yaml : Use the dev-libs/libyaml library to enable Crystal yaml module

安装

su -
emerge -a dev-lang/crystal

macOS

使用Homebre安装, 执行

brew update
brew install crystal-lang

如果你想对Crystal捐献代码,需要同时安装LLVM, 替换上面代码的最后一行为

brew install crystal-lang --with-llvm

关于在 OSX 10.11 (El Capitan)的一些问题
如果报如下的错误

ld: library not found for -levent

你需要重装命令行工具,并选择默认的工具链

$ xcode-select --install
$ xcode-select --switch /Library/Developer/CommandLineTools

在Linux中使用Linuxbrew

可以在Linux发行版中使用Linuxbrew安装Crystal

brew update
brew install crystal-lang

如果你想对Crystal捐献代码,需要同时安装LLVM, 替换上面代码的最后一行为

brew install crystal-lang --with-llvm

Bash,Ubuntu在Windows

Crystal目前还不支持windows系统, 如果你使用的是Windows10 你可以尝试使用Bash on Ubuntu on Windows
(win10红石版的一个Bash环境)来安装, 安装方式跟Ubuntu的安装方式一致,但可能还是会有些问题(这是一个实验性的尝试)

添加源

curl -sSL https://dist.crystal-lang.org/apt/setup.sh | sudo bash

sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54
echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list
sudo apt-get update

依赖问题

需要安装C的编译器(cc) 和连接器(ld )

sudo apt-get install clang binutils

安装

sudo apt-get install crystal

版本更新

sudo apt-get update
sudo apt-get install crystal

通过tar.gz文件

如果你不想使用前面的任何一种安装方法, 你可以下载Crystal的单文件版本。最新版本的Github地址是 https://github.com/crystal-lang/crystal/releases
下载对应平台的版本,在包中有一个 bin/crystal的可执行文件, 创建一个符号链接到你的系统Path环境变量目录

ln -s [full path to bin/crystal] /usr/local/bin/crystal  

这样就可以直接输入 ctystal 命令来使用了

Crystal 0.28.0 发布,改进的语言、范围、库查找等  https://www.linuxidc.com/Linux/2019-04/158223.htm

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

栗子博客 软件 Ubuntu/Linux/Windows/macOS 下安装 Crystal https://www.lizi.tw/soft/14224.html

常见问题
  • 1、杰齐1.7仅适用于PHP5.2 2、需Zend支持 3、尽量使用宝塔面板 4、尽量使用Windows 系统,关关对Linux支持不太友好。
查看详情

相关文章

评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

Ubuntu/Linux/Windows/macOS 下安装 Crystal-海报

分享本文封面