Skip to content

All required libraries

TheEEs edited this page Jul 16, 2022 · 73 revisions

This is a list of known required libraries needed to build Crystal from source, and run Crystal's specs.

General

  • You will need a supported LLVM version.

  • You will also need Boehm GC 7.6 or greater (because of this commit).

    If your distro does not have a new enough package, one way is to install the latest bdw from git master.
    You may need autoreconf, automake, libtool, make, g++, pkg-config and diff packages for that.

    git clone https://github.com/ivmai/bdwgc.git
    cd bdwgc
    git clone https://github.com/ivmai/libatomic_ops.git
    autoreconf -vif
    ./configure --enable-static --disable-shared
    make -j
    make check
    sudo make install

    Note: For experimental multi-thread, an upstream patch from bdw git master is needed unless you're using version 8.2.0+. The compiler ships with an embedded GC with this patch already.

To build Crystal, a requirement is to have a working version of Crystal itself already installed, see one of the non "from sources" options, or use cross compilation to bootstrap a compiler for your current OS.

Debian/Ubuntu

sudo apt-get install -y \
  automake \
  build-essential \
  git \
  libbsd-dev \
  libedit-dev \
  libevent-dev \
  libgmp-dev \
  libgmpxx4ldbl \
  libpcre3-dev \
  libssl-dev \
  libtool \
  libxml2-dev \
  libyaml-dev \
  lld \
  llvm \
  llvm-dev\
  libz-dev

Fedora

sudo dnf -y install \
  gcc \
  gcc-c++ \
  gmp-devel \
  libbsd-devel \
  libedit-devel \
  libevent-devel \
  libxml2-devel \
  libyaml-devel \
  llvm-devel \
  llvm-static \
  libstdc++-static \
  make \
  openssl-devel \
  pcre-devel \
  redhat-rpm-config

Note that if you use a specific version of llvm, you may need to specify it, like make LLVM_CONFIG=llvm-config-9.0-64

macOS (with homebrew)

You may find some more up-to-date packages in ./bin/ci (see the brew install commands in the prepare_build function.)

xcode-select --install # shouldn't be needed, homebrew installs it for you
brew install \
  bdw-gc \
  gmp \
  libevent \
  libxml2 \
  libyaml \
  llvm@11 \
  openssl \
  pcre \
  pkg-config
brew link --force llvm@11 # it'll fail and give you instructions for adding llvm your PATH, do it and restart the terminal

No Boehm GC from source installation is needed, as the bdw-gc brew package works well.

Done!

You are now ready to build crystal, you can run make help from the crystal source dir to see options available.