This guide will help you build and install the Cx compiler from source.
To build Cx, you need the following tools installed on your system:
- LDC2 (The LLVM D Compiler)
- DUB (The D package manager)
- A C Compiler (GCC or Clang, used by Cx to compile the final output)
Ubuntu / Debian:
sudo apt update
sudo apt install ldc dub gccArch Linux:
sudo pacman -S ldc dub gccFedora:
sudo dnf in ldc dub gccThe repository includes an automated build script that handles dependency checking, compilation, and installation.
- Clone the repository:
git clone https://github.com/FernandoTheDev/cx.git
cd cx- Run the build script:
./build.shThis script will:
- Verify that
ldc2anddubare installed. - Build the compiler in
releasemode. - Copy the
cxbinary to~/.local/bin/. - Install the standard library to
~/.cx/std/.
- Add
~/.local/binto your PATH (if not already added):
- Bash:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc - Zsh:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc - Fish:
fish_add_path $HOME/.local/bin
- Verify the installation:
cx -vExpected output: Cx Compiler - Version (0.x.x)
If you prefer not to use the automated script, you can build and install manually:
- Build the release binary:
dub build --compiler=ldc2 --build=release- Move the binary to your local bin directory:
mkdir -p ~/.local/bin
cp ./cx ~/.local/bin/- Copy the standard library:
mkdir -p ~/.cx
cp -r ./std ~/.cx/stdCx has a built-in update mechanism. To check for and install the latest version, simply run:
cx updateTo ensure everything is working correctly on your machine, you can run the compiler's test suite:
rdmd tests/unit.dThis will compile and execute all examples in the examples/ directory, verifying both the exit codes and the standard output.
To completely remove Cx from your system:
rm ~/.local/bin/cx
rm -rf ~/.cx(Don't forget to remove the PATH export from your ~/.bashrc or ~/.zshrc if you added it).