Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile a C file without visual studio

I have visual studio 2008. I have a written a small C program. I want to compile that C file in command prompt. How do i do that ? please point me to a place where i can learn more about working with projects without visual studio.

thanks

like image 508
Anand Avatar asked Jul 12 '09 10:07

Anand


Video Answer


2 Answers

If you have Visual Studio, you also have the command line C compiler, which Visual Studio invokes when it builds your project. So you just have to invoke it from the command line.

You can also download a C compiler for free, there are a lot of options available, such as http://gcc.gnu.org/releases.html, or see http://www.thefreecountry.com/compilers/cpp.shtml

If we assume you are using the Microsoft C/C++ Compiler (cl.exe which will be in the VC subdirectory of your Visual Studio installation), open the Visual Studio command prompt (it will have appropiate paths set). In order to compile a file called "helloworld.c", type:

cl helloworld.c

For more information, see the MSDN docs.

like image 90
driis Avatar answered Oct 03 '22 23:10

driis


%comspec% /k ""c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86

run above code in command prompt (visual studio 2010, editor: notepad.exe recommend)

c:\temp> cl.exe hello.c

like image 41
plan9assembler Avatar answered Oct 03 '22 23:10

plan9assembler