Compiling and Executing in Windows CMD

Hi all,

I have been writing some C++ programs in Microsoft Visual Studio Express 2013 for Windows Desktop and I would like to start writing my programs using Notepad and be able to compile, link and execute them from Windows cmd box, so as I could give my programs command line arguments. The questions I have are:

1. Since Visual Studio already comes with a compiler, can I use it or will I need to download another compiler like g++ or mingw?

2. Would it be possible to do all of this in Windows Powershell?

I have searched Google with some less than optimal results. My ultimate goal is to start writing code with out the help of Visual Studio. VS is nice, however, I feel that it is going to end up hindering me in the long run. Thank you for any and all help.
1. Yes you can use the Visual C++ compiler from the command line (I was doing so earlier today)

Walkthrough: Compiling a Native C++ Program on the Command Line
https://msdn.microsoft.com/en-us/library/ms235639.aspx

2. Yes, you can use Powershell if you want. But I just use a regular command prompt. There's no need to use Powershell unless you need its power.

Everywhere I have worked as a professional developer on Windows applications we have used Visual Studio, so knowing how to use it (well) won't hinder you. But understanding how to build application on the command line will help, too. Though I only ever use it for small scale programs.

And finally, even if you build your app using Visual Studio, there's nothing to stop you from opening a command prompt and running it there; you don't have to run it via the IDE just because that's how you built it.

And the Visual Studio debugger configuration allows you to specify command line arguments to feed to your app, too. More useful for debugging rather than just running, when you might as well use a command prompt.
Last edited on
Visual Studio is a very powerful tool when used for debugging. If you do not rely on intellisense and the ability for it to finish and auto generate definitions, I do not think it will hinder you. Creating a custom theme will also allow for greater speed(in my case) to write and read code.

If you think it will hinder you, then I suggest trying other text editors and shells. Also, if an admin on windows, Shift+Right-Click in a folder will give the option to open a command prompt in that directory.
Thank you for responses. I heard Cygwin was a good alternative, so I downloaded it, but it just doesn't really seem to fit what I'm after. As for relying on Intellisense, that probably my biggest downfall.
You can try MinGW. Its what i use along with notepad++ It seams to be working for me, but i haven't been Coding for very long.
I think I would agree with Shifty189 - MinGW is very good. It includes the g++ compiler.
It's actually the suite of all gnu compilers, so you can optionally install fortran, ada, and other language compilers if you like as well.

A standard Windows Command Window is perfectly adequate, and you can use any text editor that you like. I just use standard Windows NotePad (to cut-and-paste code from this forum) and then a line-based, but scriptable and highly-tailorable editor called THE (http://hessling-editor.sourceforge.net/) to do most of my own coding.

An advantage of this set-up is that you end up issuing the same g++ compile commands that you would issue in any other OS, including linux. In fact, MinGW optionally allows you to install MSYS and run linux commands in a local linux-like environment and filesystem.

Being able to run in a Command Window is a useful skill to have. You can do batch processing, use wildcards, ... and you never know when useful little commands like 'taskkill' will come in handy when you've managed to launch 1000+ versions of the same process!
Last edited on
Topic archived. No new replies allowed.