Skip to content

All required libraries

Johannes Müller edited this page Mar 5, 2024 · 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
    ./autogen.sh
    ./configure --enable-static --disable-shared --enable-large-config
    make -j CFLAGS=-DNO_GETCONTEXT
    make check
    sudo make install

Note

For experimental multi-threading, 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 \
  libevent-dev \
  libgmp-dev \
  libgmpxx4ldbl \
  libpcre2-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 \
  libevent-devel \
  libxml2-devel \
  libyaml-devel \
  llvm-devel \
  llvm-static \
  libstdc++-static \
  make \
  openssl-devel \
  pcre2-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 \
  openssl \
  pcre2 \
  pkg-config

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.