Want To Download Pre-Built C3 Binaries?
Download C3, available on Mac, Windows and Linux.
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 the LLVM documentation on how to set up LLVM for development. - On MacOS, installing through Homebrew or MacPorts works fine. - Using apt-get on Linux should work fine as well. - For Windows you can download suitable pre-compiled LLVM binaries from here.
2. Clone the C3 compiler source code from Github¶
This should be as simple as doing:
... from the command line.
3. Build the compiler¶
Create the build directory:
Use CMake to set up:
Build the compiler:
4. Test it out¶
Building via Docker¶
You can build c3c using either an Ubuntu 18.04 or 20.04 container:
Replace 18 with 20 to build through Ubuntu 20.04.
For a release build specify:
A c3c executable will be found under bin/.
Building on Mac using Homebrew¶
- Install CMake:
brew install cmake - Install LLVM 17+:
brew install llvm - Clone the C3C github repository:
git clone https://github.com/c3lang/c3c.git - Enter the C3C directory
cd c3c. - Create a build directory
mkdir build - Change directory to the build directory
cd build - Set up CMake build for debug:
cmake .. - Build:
cmake --build .
Building on Mac using MacPorts¶
c3c may be built on Mac systems not supported by Homebrew using the cmake, llvm-17 and clang-17 ports from MacPorts.
- Install CMake:
sudo port install cmake - Install LLVM 17:
sudo port install llvm-17 - Install clang 17:
sudo port install clang-17 - Clone the C3C github repository:
git clone https://github.com/c3lang/c3c.git - Enter the C3C directory
cd c3c. - Create a build directory
mkdir build - Change directory to the build directory
cd build - ❗️Important before you run cmake❗️
Set LLVM_DIR to the directory with the llvm-17 macport .cmake files
export LLVM_DIR=/opt/local/libexec/llvm-17/lib/cmake/llvm - Set up CMake build for debug:
cmake .. - Build:
cmake --build .
See also discussion #1701