A minimal x86 operating system kernel written in C++, booted using GRUB, and run in QEMU. This kernel boots directly into VGA text mode and displays a simple terminal output.
Designed for learning Operating System Development from scratch using modern tools.
- ✅ Boots using GRUB (Multiboot)
- ✅ Written in freestanding C++
- ✅ VGA text-mode terminal
- ✅ Runs on QEMU
- ✅ Clean & beginner-friendly codebase
.
├── boot/
│ └── grub/
│ └── grub.cfg
├── kernel/
│ ├── kernel.cpp
│ ├── terminal.cpp
│ └── terminal.hpp
├── linker.ld
├── Makefile
└── README.md
This project is designed to run on Windows using WSL (Ubuntu).
- Windows 10/11 with WSL 2
- Ubuntu (via WSL)
- VS Code with Remote - WSL extension
- QEMU
- GRUB tools
i686-elf-gcccross compiler
Open PowerShell as Administrator and run:
wsl --install- Reboot when prompted
- After reboot, open Ubuntu from Start Menu
- Set your username and password
sudo apt update && sudo apt upgrade -ysudo apt install -y \
build-essential \
bison \
flex \
libgmp3-dev \
libmpc-dev \
libmpfr-dev \
texinfo \
grub-pc-bin \
grub-common \
xorriso \
qemu-system-x86Verify installation:
grub-mkrescue --version
qemu-system-i386 --versionmkdir ~/cross
cd ~/crosswget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.xz
tar -xf binutils-2.41.tar.xz
mkdir build-binutils
cd build-binutils
../binutils-2.41/configure \
--target=i686-elf \
--prefix=/usr/local/cross \
--with-sysroot \
--disable-nls \
--disable-werror
make -j$(nproc)
sudo make installcd ~/cross
wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz
tar -xf gcc-13.2.0.tar.xz
mkdir build-gcc
cd build-gcc
../gcc-13.2.0/configure \
--target=i686-elf \
--prefix=/usr/local/cross \
--disable-nls \
--enable-languages=c,c++ \
--without-headers
make all-gcc -j$(nproc)
make all-target-libgcc -j$(nproc)
sudo make install-gcc
sudo make install-target-libgccecho 'export PATH="/usr/local/cross/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcVerify:
i686-elf-gcc --versionYou should see output indicating the cross-compiler is installed.
- Install Remote - WSL extension in VS Code
- From Ubuntu terminal:
cd ~/your-project-folder
code .VS Code will reopen inside WSL.
In the VS Code terminal (or Ubuntu terminal):
make clean
make
make runA QEMU window will open showing:
Welcome to My C++ Kernel!
Booted successfully into terminal mode.
Solution:
source ~/.bashrcMake sure /usr/local/cross/bin is in your PATH.
Solution:
sudo apt install grub-pc-bin xorrisoCheck:
- Architecture is
i686 - Kernel is compiled with
-ffreestanding - GRUB config path is correct in
boot/grub/grub.cfg - Multiboot header is properly defined in
kernel.cpp
Common issues:
- Missing dependencies: ensure all packages from Step 3 are installed
- Disk space: cross-compiler builds require ~5GB
- Build time: GCC compilation can take 20-60 minutes depending on your CPU
- OSDev Wiki
- GRUB Multiboot Specification
- Intel x86 Developer Manuals
- Writing a Simple Operating System from Scratch
- Keyboard driver
- Scrollable terminal
- Interrupt handling (IDT)
- Memory management
- 64-bit long mode
- Simple shell
MIT License – Feel free to fork, modify, and learn.
Pull requests are welcome! If you're learning OS development, this project is a great starting point.
Special thanks to the OSDev community for their extensive documentation and resources.
Happy hacking! 🚀