Skip to content

Required libraries

This is a list of third-party libraries used by the Crystal compiler and the standard library.

Core runtime dependencies

The libraries in this section are always required by Crystal's stdlib runtime. They must be present for building or running any Crystal program that uses the standard library. Avoiding these dependencies is only possible when not using the standard library (--prelude=none compiler option).

System library

A major component is the system library. Selection depends on the target platform and multiple are supported. This usually includes the C standard library as well as additional system libraries such as libdl, libm, libpthread, libcmt, or libiconv which may be part of the C library or standalone libraries. On most platforms all these libraries are provided by the operating system.

Library Description License
glibc standard C library for Linux LGPL
musl libc standard C library for Linux MIT
FreeBSD libc standard C library for FreeBSD BSD
NetBSD libc standard C library for NetBSD BSD
OpenBSD libc standard C library for OpenBSD BSD
Dragonfly libc standard C library for DragonflyBSD BSD
macOS libsystem standard C library for macOS Apple
MSVCRT standard C library for MSVC compiler (Windows)
WASI WebAssembly System Interface Apache v2 and others
bionic libc C library for Android BSD-like

Other runtime libraries

Library Description License
Boehm GC The Boehm-Demers-Weiser conservative garbage collector. Performs automatic memory management. MIT-style
Libevent An event notification library. Implements concurrency features such as Fiber and the event loop on POSIX platforms. Not used on Windows. Modified BSD
compiler-rt builtins Provides optimized implementations for low-level routines required by code generation, such as integer multiplication. Several of these routines are ported to Crystal directly. MIT / UIUC

Optional standard library dependencies

These libraries are required by different parts of the standard library, only when explicitly used.

Regular Expression engine

Engine implementation for the Regex class. PCRE2 support was added in Crystal 1.7 and it's the default since 1.8 (see Regex documentation).

Library Description License
PCRE2 Perl Compatible Regular Expressions, version 2. BSD
PCRE Perl Compatible Regular Expressions. BSD

Big Numbers

Implementations for Big types such as BigInt.

Library Description License
GMP GNU multiple precision arithmetic library. LGPL v3+ / GPL v2+
MPIR Multiple Precision Integers and Rationals, forked from GMP. Used on Windows. GPL-3.0 and LGPL-3.0

Internationalization conversion

This is either a standalone library or may be provided as part of the system library on some platforms. May be disabled with the -Dwithout_iconv compile-time flag. Using a standalone library over the system library implementation can be enforced with the -Duse_libiconv compile-time flag.

Library Description License
libiconv (GNU) Internationalization conversion library. LGPL-3.0

TLS

TLS protocol implementation and general-purpose cryptographic routines for the OpenSSL API. May be disabled with the -Dwithout_openssl compile-time flag.

Both OpenSSL and LibreSSL are supported and the bindings automatically detect which library and API version is available on the host system.

Library Description License
OpenSSL Implementation of the SSL and TLS protocols Apache v2 (3.0+), OpenSSL / SSLeay (1.x)
LibreSSL Implementation of the SSL and TLS protocols; forked from OpenSSL in 2014 ISC / OpenSSL / SSLeay

Other stdlib libraries

Library Description License
LibXML2 XML parser developed for the Gnome project. Implements the XML module. MIT
LibYAML YAML parser and emitter library. Implements the YAML module. MIT
zlib Lossless data compression library. Implements the Compress module. May be disabled with the -Dwithout_zlib compile-time flag. zlib
LLVM Target-independent code generator and optimizer. Implements the LLVM API. Apache v2 with LLVM exceptions

Compiler dependencies

In addition to the core runtime dependencies, these libraries are needed to build the Crystal compiler.

Library Description License
PCRE2 See above.
LLVM See above. Apache v2 with LLVM exceptions
libffi Foreign function interface. Used for implementing binary interfaces in the interpreter. May be disabled with the -Dwithout_interpreter compile-time flag. MIT