Skip to content

Build C3 From Source

For other platforms it should be possible to compile it on any platform LLVM can compile to. You will need git and CMake installed.

1. Install LLVM

See LLVM the LLVM documentation on how to set up LLVM for development.

  • On MacOS, installing through Homebrew works fine.
  • Using apt-get on Linux should work fine as well.
  • For Windows you can download suitable pre-compiled LLVM binaries from https://github.com/c3lang/win-llvm

2. Clone the C3 compiler source code from Github

This should be as simple as doing:

Terminal window
git clone https://github.com/c3lang/c3c.git

… from the command line.

3. Build the compiler

Create the build directory:

Terminal window
MyMachine:c3c$ mkdir build
MyMachine:c3c$ cd build/

Use CMake to set up:

Terminal window
MyMachine:c3c/build$ cmake ../

Build the compiler:

Terminal window
MyMachine:c3c/build$ make

4. Test it out

Terminal window
MyMachine:c3c/build$ ./c3c compile-run ../resources/testfragments/helloworld.c3

Building via Docker

You can build c3c using either an Ubuntu 18.04 or 20.04 container:

Terminal window
./build-with-docker.sh 18

Replace 18 with 20 to build through Ubuntu 20.04.

For a release build specify:

Terminal window
./build-with-docker.sh 20 Release

A c3c executable will be found under bin/.

Building on Mac using Homebrew

  1. Install CMake: brew install cmake
  2. Install LLVM 17+: brew install llvm
  3. Clone the C3C github repository: git clone https://github.com/c3lang/c3c.git
  4. Enter the C3C directory cd c3c.
  5. Create a build directory mkdir build
  6. Change directory to the build directory cd build
  7. Set up CMake build for debug: cmake ..
  8. Build: cmake --build .