Question:
How do I compile a C file through the windows command line? ?
jjjones42003
2009-01-23 20:00:47 UTC
Every time I try to "Build Solution" I get an error that says "Error spawning cmd.exe". Any idea how to fix this? Can i just compile and run C files through the Windows command line?
Four answers:
JahMic
2009-01-26 22:28:07 UTC
What you really need is to figure out why you are getting that error in the first place. You need to figure which part of the build steps is trying to call cmd.exe and why is it falling. Most likely, either your Visual studio paths or your system paths are not properly set.



But to your direct question:



Assuming you are using Visual Studio ('build solution' sounds like it), try the following:



If you have .NET installed, find the path to your msbuild.exe and add that to your windows system path. MSBUILD should be able to your SLN file as argument.



If not, you have to add the low level tools to cmd line. Warning: This is usually 10 * harder then compiling in VS.



you first need to add your compiler path to your windows system path.



Find where your cl.exe is located (example, mine is located at: "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin")



Add that to your system path by going to:

Start -> My Computer -> [Left-Click] -> Properties -> Advanced -> Environment Variables

Find the PATH variable and add your cl.exe path to that.



open a command box and try cl.exe. But compiling is only part of it, you have to link, etc. If you never built on the command line before, there are a lot of steps.
?
2016-05-24 12:36:51 UTC
To run a program you simply type it's pathname into the shell. To COMPILE a program, you need a compiler, many of which run though the command line. If you are looking for a compiler, I'd suggest checking out mingw for windows or gcc on unix like systems
2009-01-23 20:46:16 UTC
Sure. Just run a command-line version of make.
Andreas A
2009-01-23 20:14:58 UTC
You need a C Compiler.

That's a program that translates your C program into machine code.



Look here : http://www.codeblocks.org

It's free



Or look here: http://www.bloodshed.net


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...