Use `-nographic` option when running qemu (or at least add the option to)

In WSL, it's notoriously hard to run GUI applications in general. And with qemu it's no exception.

In my case, running make eg-00.bin/run gave me the following output:

make run IMG=eg-00.bin
make[1]: Entering directory '/home/vergacas/so-2/syseg/eg/hw'
qemu-system-i386 -drive format=raw,file=eg-00.bin -net none
gtk initialization failed
make[1]: *** [Makefile:563: run] Error 1
make[1]: Leaving directory '/home/vergacas/so-2/syseg/eg/hw'
make: *** [Makefile:560: eg-00.bin/run] Error 2

Ignoring all the make messages, we have gtk initialization failed.

GTK (formerly GIMP ToolKit and GTK+) is a free software cross-platform widget toolkit for creating graphical user interfaces (GUIs).

Wikipedia

One could try to run qemu without the window opening up to avoid this error. Luckily, it's fairly straightforward to do so: add the -nographics flag to the qemu-system-i386 command, i.e., qemu-system-i386 -drive format=raw,file=eg-00.bin -net none -nographic.

As WSL keeps gaining popularity, it could be a good idea to fully transition to nographic mode. But if there are still some perks to keeping the graphic mode around, it might be smart to offer the option to run in nographic mode too (?). Maybe having a command such as make eg-00.bin/run -nographic?


If you try running the command mentioned above, you might find yourself stuck in qemu's interface (kinda like when you first try vim). It's easy enough to google it and find out you need to hit CTRL + A then X to get out of qemu. But a little heads-up message on how to exit would be pretty handy for users.