Edit: To anyone interested in doing this, take a look at my answer below. I got this working exactly as I was hoping to.
I know this is a topic that has probably been addressed before, but I can't seem to find a straight answer in the searching I've done, everything is extremely convoluted.
I'm trying to get my Powershell set up so I can compile simple C programs directly from a Powershell terminal, and not need to use Visual Studio or the "developer console" they keep recommending.
So far I have installed the Visual Studio build tools, as I was trying to avoid downloading the entire Visual Studio IDE. I was able to compile a Hello World C program using the developer console as a test to make sure everything was working and it compiled and ran fine. However I want to be able to run cl.exe directly from Powershell without using the developer console.
I managed to add a folder to the environment variables in Windows System properties, and successfully got Powershell to recognize the cl command and show me this:
usage: cl [ option... ] filename... [ /link linkoption... ]
I feel like I'm so close here, but when I actually try to run "cl hello.c" to compile my little test program I get this error:
hello.c(1): fatal error C1034: stdio.h: no include path set
I added the folder "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64" to the environment variables path section, but I noticed there are multiple cl.exe files in different folders.
Can anyone tell me how to dial this thing in so I can actually have the cl function fully functioning from Powershell? Thanks in advance for any help on this.
P.S. I have WSL installed and have multiple Raspberry Pis that I could use the gcc compiler, but that is not my aim here. I'm also aware of things like MinGW and Cygwin but am not looking to use those solutions. I am trying to get this specific scenario to work: using the cl command in Powershell without the developer console. It can't be THAT hard, and I feel like I'm so close and just need to add a few more Environment variables or something.
Here's a screenshot of me trying the cl command in PowerShell and the error it gives. https://i.sstatic.net/tu62f.jpg