Figuring out even a basic toolchain for OS development on Windows is a nightmare. Thankfully, I’ve gone through it so you don’t have to.

The code of the actual OS comes from the Bare Bones tutorial on OSdev.org. Give it a read.

You’ll need these 3 tools:

1. MinGW

Download and run the MinGW installer. The installation directory defaults to C:\MinGW\ – it doesn’t matter what it is as long as you can find it later.

None of the other installation preferences matter—you’re free to leave them as they are. Besides creating shortcuts and downloading files, the installer doesn’t mess with the system or registry.

After finishing downloading, the installer will launch the MinGW Installation Manager.

It should already be on the Basic Setup page. Right click on each of the 7 packages presented and mark them for installation. (You will need to do this individually. Yes, it’s stupid.) After that, choose Installation → Apply Changes from the menu, and wait for it to finish.

2. i686-elf targeting GCC

Download and extract a prebuilt i686-elf targeting GCC for a Windows host. In this example, I’ve extracted it to C:\software\ghost-i686-elf-tools – it doesn’t matter where it is as long as you can find it later.

If this link goes dead, try finding another at the OSdev wiki. If there’s none to be found, you will need to build your own GCC cross-compiler (Good luck!).

3. QEMU

Download and install the latest QEMU for Windows installer – usually in C:\Program Files\qemu – again, it doesn’t matter where it is as long as you can find it later.

The actual OS code

Using code from the Bare Bones tutorial on OSdev.org, I’ve organised the files thus:

/build/linker.ld

/ExampleOS/boot.s

/ExampleOS/kernel.c

Getting it to build

The tutorial uses commands, so we’ll be using a batch file: build.bat

Instead of editing your global Windows PATH var, you can just set it for the current batch file:

SET "minGW=C:\MinGW\bin" SET "gcc=C:\software\ghost-i686-elf-tools\bin" SET "qemu=C:\Program Files\qemu" SET "PATH=%minGW%;%gcc%;%qemu%;%PATH%"

Compile the assembly and C code into objects, as in the tutorial:

i686-elf-as ExampleOS/boot.s -o build/boot.o i686-elf-gcc -c ExampleOS/kernel.c -o build/kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra

Link the objects using the linker.ld file:

cd build i686-elf-gcc -T linker.ld -o ../bin/boot/exampleos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc cd ..

Here, the tutorial goes on to create a bootable ISO with GRUB and grub-mkrescue, but it’s nigh impossible to get the GRUB binaries on Windows. Thankfully, QEMU can boot directly from the .bin ROM file:

qemu-system-i386 -kernel bin/boot/exampleos.bin

Then, run the batch file and you’re in kernel world!

Why do I need MinGW?

GCC needs it.

I don’t like that. How do I remove MinGW?

You can just delete the folder (and shortcuts). Thankfully it doesn’t change your PATH variable or mess with the system besides just downloading files.

Can I use Bochs or VMware or whatever?

Maybe. I’ve only been able to find out how to launch and boot a VM with a ROM from command line in QEMU.

tl;dr