C3 is a programming language designed to be a modern alternative to C with a focus on simplicity and safety. It aims to retain the low-level control and efficiency that C offers, while introducing features that make development more productive and less error-prone. This tutorial shows how to install C3 on Ubuntu 24.04.
Prepare environment
C3 requires GNU C compiler. Install it using the following command:
sudo apt install -y gcc
Install C3
Download tar.gz
file from GitHub releases page:
wget -qO c3.tar.gz https://github.com/c3lang/c3c/releases/latest/download/c3-linux.tar.gz
Extract the tar.gz
file to specified directory:
sudo tar xf c3.tar.gz -C /opt
We can create a symbolic link to the c3c
command in the /usr/local/bin
directory:
sudo ln -s /opt/c3/c3c /usr/local/bin/c3c
Now c3c
can be used as a system-wide command for all users. Verify the installation by checking the C3 version:
c3c --version
Remove no longer needed file:
rm -rf c3.tar.gz
Testing C3
Create a main.c3
file:
nano main.c3
Add the following code:
module hello_world;
import std::io;
fn void main()
{
io::printn("Hello world");
}
Compile a code:
c3c compile main.c3 -o test
Run a program:
./test
Uninstall C3
To completely remove C3, delete the installation directory:
sudo rm -rf /opt/c3
Remove symbolic link:
sudo rm -rf /usr/local/bin/c3c
Leave a Comment
Cancel reply