Installing GCC
ABC is written in C, so before we can compile the engine we need a C compiler. GCC is used to turn the ABC source code into an executable program, and the same build process works on both Windows and Linux.
GCC, the GNU Compiler Collection, is one of the most widely used C compilers. It takes our C source files and compiles them into machine code that can be executed by the operating system.
Windows
On Windows, one of the simplest ways to install GCC is through MSYS2. After installing MSYS2, open the MSYS2 UCRT64 terminal and install GCC with:
pacman -S mingw-w64-ucrt-x86_64-gcc
After the installation finishes, verify that GCC is available:
gcc --version
If the command prints the GCC version, the compiler is ready.
Linux
On Linux, GCC can normally be installed through the distribution's package manager. On Ubuntu or another Debian-based distribution:
sudo apt update
sudo apt install gcc
On Fedora:
sudo dnf install gcc
On Arch Linux:
sudo pacman -S gcc
After installation, verify GCC with:
gcc --version
Building ABC
ABC includes a Makefile that contains the complete command used to build the engine. Instead of entering the GCC command manually, we can simply run:
make
The Makefile tells make exactly how ABC should be compiled. In the current version of ABC, the build command is:
gcc -Ofast -flto *.c -o abc.exe
The *.c tells GCC to compile all C source files in the current directory. The -o option specifies the name of the resulting executable.
The -Ofast option enables aggressive compiler optimizations, while -flto enables link-time optimization. These options are useful when building the engine for performance.
On Linux, the Makefile can use the same GCC options while producing an executable without the Windows .exe extension:
gcc -Ofast -flto *.c -o abc
The important part is that you normally do not need to type either command yourself. Run make, and the Makefile takes care of the build.
Once GCC and Make are installed, ABC can be compiled on both Windows and Linux using the same simple build process.