A GUI-based calculator developed in C using GTK.
This document outlines the requirements, dependencies, and tools needed to build and run the C GUI Calculator project, a cross-platform calculator built using C and GTK+ 3.
The C GUI Calculator requires:
| Component | Version | Purpose | Status |
|---|---|---|---|
| gcc | 7.0+ | GNU Compiler Collection for compiling C source code | ✅ Required |
| pkg-config | 0.29+ | Manages compiler/linker flags for libraries | ✅ Required |
| GTK+ 3 | 3.22+ | GUI toolkit for creating the calculator interface | ✅ Required |
| GLib | 2.56+ | Low-level system library (included with GTK+) | ✅ Required |
| make | 4.0+ | Build automation tool | 📋 Optional |
| git | 2.0+ | Version control system | 📋 Optional |
sudo apt update && sudo apt upgrade -y
sudo apt install gcc pkg-config libgtk-3-dev build-essential
# Fedora/RHEL 8+
sudo dnf update -y
sudo dnf groupinstall "Development Tools" -y
sudo dnf install gcc pkgconf-pkg-config gtk3-devel
# CentOS/RHEL 7
sudo yum groupinstall "Development Tools"
sudo yum install gcc pkgconfig gtk3-devel
sudo pacman -Syu
sudo pacman -S base-devel gtk3 pkg-config
pacman -Syu
pacman -S base-devel mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gtk3
Important: Always use the MSYS2 MinGW 64-bit terminal, not the default MSYS2 terminal.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg install gtk:x64-windows
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
xcode-select --install
brew install gcc pkg-config gtk+3
brew install --cask xquartz
sudo port install gcc12 pkgconfig gtk3
sudo port select --set gcc mp-gcc12
After installation, verify your environment:
# Check compiler
gcc --version # Should show GCC 7.0+
# Check pkg-config
pkg-config --version # Should show 0.29+
# Check GTK+ 3
pkg-config --exists gtk+-3.0 && echo "✅ GTK+ 3 found" || echo "❌ GTK+ 3 missing"
pkg-config --modversion gtk+-3.0 # Should show 3.22+
# Test compilation
echo '#include <gtk/gtk.h>\nint main(){return 0;}' > test_gtk.c
gcc test_gtk.c $(pkg-config --cflags --libs gtk+-3.0) && echo "✅ GTK+ compilation works"
rm test_gtk.c a.out 2>/dev/null
| Issue | Solution |
|---|---|
| “Package gtk+-3.0 was not found” | Install GTK+ development packages for your OS |
| “pkg-config: command not found” | Install pkg-config package for your OS |
| GTK+ app doesn’t display on macOS | Install and launch XQuartz (X11) |
| Wrong MSYS2 environment on Windows | Use MinGW64 terminal, verify prompt shows “MINGW64” not “MSYS” |
build-essential package includes GCC and other essential toolssudo apt install git (Linux) or brew install git (macOS)Need Help?