Saturday, March 5, 2016

How to compile C/C++ programs from command line with Visual Studio

On the subject "compiling from command line with Visual Studio" the Microsoft's page is pretty well done, with some hello world examples for the typical cases (C, C++, .NET etc): https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx

Short version:

Run the command (this will basically open the cmd.exe and the correct environment variables):

Start -> Visual Studio 2015 ->  Visual Studio Tools -> Developer Command Prompt for VS2015

Move to the directory where your C file is located and run the command:


cl <your_C_file>

if you want to compile a C++ program instead:


cl /EHsc <your_C++_file>


That's it.

On the Microsoft's page, you can find many more options.

No comments:

Post a Comment

Your comment will be visible after approval.