Reputation: 10400
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
Upvotes: 6
Views: 17180
Reputation: 5885
If you're talking about not using the IDE GUI, an alternative is to set up a project for your C file as you normall would and call devenv.com to compile that project. It will then pass all the required paths and settings to the compiler and linker. We use that to compile some projects on our build servers. To learn more, type 'devenv.com /?'.
Regards,
Sebastiaan
Upvotes: 1
Reputation: 3138
Compiling the 'c' file from command line is easy and you have many answers to start with. However working with projects is a different thing and you will need to have a tool that will do it. Microsoft nmake was mentioned before, but i will suggest using gnu make utility that used for managing build. It is compiler independent, old (meaning proven) and very flexible tools that will allow you to create very robust build environment.
Upvotes: 0
Reputation: 499312
Lots of options out there. As mentioned by driis, there are lots of free c compilers available to download.
If you just want to compile code on a machine that has visual studio on it, microsoft offers several tools that allow command line use and project management:
Microsoft have reference documents for command line building.
Another options is MonoDevelop - an open source ide that understand visual studio project files.
Upvotes: 0
Reputation: 2984
%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
Upvotes: 2
Reputation: 164341
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.
Upvotes: 8
Reputation: 19273
Read more about that here: http://msdn.microsoft.com/en-us/library/ms235639(VS.80).aspx
MSDN is a great source for more information.
Upvotes: 0