Windows C Development:
Author: Scott Dye

There are various methods of developing C programs in Windows, but most of them end up just using Linux (Virtual machines, Windows Subsystem for Linux, or dual booting).

Windows Subsystem for Linux:
The easiest method is probably setting up your Windows Subsystem for Linux and installing gcc, make, and git. This method allows you to just use the normal Unix terminal commands and interact with your Windows computer/file system just like any Linux computer. I personally find one drawback with this method - you can only use Microsoft's Visual Studio Code IDE to debug your code (a valuable resource) because Windows doesn't have a C compiler. You can use VS Code because Microsoft made it work with Windows Subsystem for Linux and the Linux compiler that you will install. You will need to open Windows PowerShell (recommended) or the Windows Command Prompt. You need to preface all of your commands with wsl:
wsl sudo apt-get install gcc
wsl sudo apt-get install make
wsl sudo apt-get install git
or run wsl to make the terminal work like a Linux terminal, then run the commands.
wsl
sudo apt-get install gcc
sudo apt-get install make
sudo apt-get install git
To open your current folder in VS Code, you need to type the following command in the terminal:
wsl code .
or if you already made the terminal behave like a Linux terminal:
code .
Windows:
Doing the following will allow you to write C code and compile and run it directly within Windows, without dealing with Linux (also allowing you to use any IDE's debugger). I also included instructions for installing Git.

C Compiler:
First, and most importantly, you will need a Windows compatible C compiler, such as MinGW. I personally used this MinGW Installation Manager because it can be a headache to deal with installing MinGW and this one makes it really simple. If you want the simplest installation, just install everything in the "Basic Setup" menu and that is everything you need for this class and most development. There are optional packages that you can install if you want to do more advanced C development, such as a Windows implementation of the commonly used multithreading library pthreads.

Next, to be able to use the gcc and make commands in your terminal, you need to add the location of MinGW's executables (binaries) to the terminal's Path environment variable. You can do this via the terminal or the gui. Note: I saved MinGW to the folder C:\MinGW, if you save yours elsewhere, your path will be different than mine.

Terminal:
I recommend using Windows Powershell because it allows you to use most of the commonly used Linux terminal commands, but this can be done just as well through the Windows Command Prompt (but may require using a different command).
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\MinGW\bin")
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\MinGW\msys\1.0\bin")
GUI:
Type "Environment Variables" into the Windows search bar and open "Edit the system environment variables". This will open a "System Properties" window. Click on the "Environment Variables" button near the bottom. This will open another window with the environment variables. Click on the variable "Path" in the "System Variables" section and click on the "Edit" button. Click the "New" button and type
C:\MinGW\bin
Click the "New" button again and type
C:\MinGW\msys\1.0\bin
Now you should be able to type the following in your terminal to see that you really have gcc and make installed.
gcc --version
make --version
Git:
You will also want to install Git. You can install the GUI Github Desktop for Windows, but I recommend installing the terminal interface for Git. Note: These instructions are for Windows PowerShell (I have never set it up for Windows Command Prompt and the commands might be different).

First, you need to check to make sure your machine's Execution Policy is not "Restricted". To do this run the following line in Windows PowerShell.
ExecutionPolicy
If it is "Restricted", you'll need to run this command:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force
To install Git, you'll run the command
Install-Module posh-git -Scope CurrentUser -Force
If it fails with an error like "Module 'PowerShellGet' was not installed by using Install-Module", you'll need to rerun the install command after running this command:
Install-Module PowerShellGet -Force -SkipPublisherCheck
Now, you'll need to tell Windows PowerShell to use the Git module. The second command adds the import command to your profile, so it imports it every time you open Windows PowerShell.
Import-Module posh-git
Add-PoshGitToProfile -AllHosts
Although it isn't necessary, I personally recommend installing an IDE (Eclipse, Visual Studio, Code Blocks, etc) if you don't already have one because they offer auto-completion and debugging tools to make your life easier and help you find where things are going wrong in your code. Some people will use just Notepad or Notepad++ to develop code, ultimately, it is up to user preference. Now you are ready to develop in C on your Windows computer!