top of page

My Workflow: Systems Programming for Linux on Window

Simple and efficient C/C++ *nix programming on Windows


System software development has always been my passion. It’s so much fun! But with languages like C/C++, it’s not always the easiest to work on Windows — especially when the OS you’re developing for isn’t Windows.

So, what do I do? Simple. I use VS Code and Virtual Machines! Aaand that’s the end of this article… Just kidding. Let me elaborate.

The Host OS

Honestly, it’s been quite a long time since I last used Windows. However, I recently got myself a new PC (yay!), so I got back to using Windows. As much as I enjoy working on Linux, gaming isn’t its biggest strength. Plus, I wanted a change.

So, here I am, typing this article because, alas, as much as I am peacefully using Windows, I can’t really do my software development work on it.

That said, I do use a couple programs to make my life a bit easy — Microsoft PowerShell Core and Microsoft Windows Terminal.

Virtualization

Since software development on Windows is a no-no for me, like any sane person I installed VirtualBox. Of course you could use Docker or some other software as well if it works for you, but I prefer to use a VirtualBox virtual machine for persistence, ease of use, and most importantly, to have the complete OS available.

A thing I always do is enable Bridged Adapter in VirtualBox VM’s Network Settings and use the generated MAC address to assign a static IP on my router for the machine. That way, the private IP is always constant for the machine and I can access all the services/ports of the machine just like I would for any other device on the network.

Setting bridged adapter as the network interface in VirtualBox -> VM Settings


The Guest OS

Ooh! Time to decide the OS/distro to use for development! Honestly, you can choose whatever you like — FreeBSD, OpenBSD, Gentoo, Arch, Ubuntu, and so on. Too many choices to even list here, only dependent on your requirements.

Historically, I have always been a fan of Gentoo and Arch distributions (I love watching software compile — guess I am weird that way 😛). However, I didn’t want to invest much time setting them up, since this is only a guest OS.

I went ahead with Ubuntu 20.04. Since I don’t use GUI and would rather like a minimal OS, I opted for Ubuntu’s Server Edition.

Host-Guest Interfacing

When using VirtualBox and starting a virtual machine, there is a nifty little trick— the drop-down button on the “Start” button allows you to start the Virtual Machine in headless mode. No window for the machine will be presented, but the machine will be running.

Starting VM in Headless mode — VirtualBox


I use SSH to connect from Windows Terminal on my machine to the virtual machine. Using SSH to connect to guest is really easy and efficient. No need to use the (often) slower GUI on virtual machine to open a terminal or, either enable host-guest copy/paste or perform some forbidden dark arts to get data across host/guest.

PowerShell on Windows Terminal, connecting to the virtual machine


As a bonus, since no desktop environment is running, the RAM usage is quite low (as visible in the image)!

Code Editor

Honestly, I like vim — simple to launch and use. But for anything more than a script file, it’s not practical. I enjoy VS Code’s interface too, and am quite accustomed to it.

The only issue with using VS Code was that the source code lies on the virtual machine. Notice the “was”? Yep! Turns out there is a (really easy) solution for that too!

If you check out VS Code’s extensions, there is one from Microsoft called Remote — SSH: Editing Configuration Files which allows you to use SSH to use VS Code as a remote editor. And it works just like it would on a local machine!

VS Code connected to VM using the Remote SSH extension


VS Code also maintains separate extensions for both local and remote so you can pick and choose per your requirements!

I cannot describe how happy I was when I discovered this feature. It was like all my worries just flew away… yeah that was probably a bit too dramatic, but you get the idea!

Conclusion

Well, that’s basically my setup for *nix system software development using Windows as my primary OS. Another significant benefit I find of using this approach is that I can just leave my PC when I am tired of sitting on a chair, get comfy on my couch/bed, and use my laptop to connect to the virtual machine and continue the work. Pretty smooth, if you ask me!

Final Setup — VS Code + Windows Terminal, connected to the VM


Anyway, that’s it for this article. I recently got into this workflow and really enjoyed it so I thought I should share. Let me know your thoughts and do share your workflow!



Source: Medium


The Tech Platform

0 comments

Comentários


bottom of page