Related to this que开发者_开发知识库stion. What's the process for compiling a C program (assume 1 file)?
Quoting http://users.actcom.co.il/~choo/lupg/tutorials/c-on-unix/c-on-unix.html:
The easiest case of compilation is when you have all your source code set in a single file.
cc single_main.c
You might complain that 'a.out' is a too generic name (where does it come from anyway? - well, that's a historical name, due to the usage of something called "a.out format" for programs compiled on older Unix systems). Suppose that you want the resulting program to be called "single_main". In that case, you could use the following line to compile it:
cc single_main.c -o single_main
It depends on what compiler/IDE you use.
With Visual Studio ctrl-shift-B
is all you need to build your project.
With gcc enter in the command line: gcc file.c -o executable_name
.
NAME
gcc - GNU project C and C++ compiler
SYNOPSIS
gcc [-c|-S|-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn...] [-pedantic]
[-Idir...] [-Ldir...]
[-Dmacro[=defn]...] [-Umacro]
[-foption...] [-mmachine-option...]
[-o outfile] [@file] infile...
Only the most useful options are listed here; see below for the remain-
der. g++ accepts mostly the same options as gcc.
DESCRIPTION
When you invoke GCC, it normally does preprocessing, compilation,
assembly and linking. [...]
精彩评论