【发布时间】:2010-01-03 13:43:38
【问题描述】:
Related to this question。编译C程序(假设1个文件)的流程是什么?
【问题讨论】:
-
您是在谈论您需要做什么来编译 C 文件,或者在编译 C 文件(预处理器、编译器、链接器、 ...)?
标签: c compilation
Related to this question。编译C程序(假设1个文件)的流程是什么?
【问题讨论】:
标签: c compilation
引用http://users.actcom.co.il/~choo/lupg/tutorials/c-on-unix/c-on-unix.html:
最简单的编译情况是将所有源代码设置在 single file 中。
cc single_main.c
您可能会抱怨“a.out”是一个过于笼统的名称(它从何而来?-嗯,这是一个历史名称,因为在编译的程序中使用了一种称为“a.out 格式”的东西较旧的 Unix 系统)。假设您希望将生成的程序称为“single_main”。在这种情况下,您可以使用以下行来编译它:
cc single_main.c -o single_main
【讨论】:
/usr/bin/cc 与 /usr/bin/gcc 是同一个文件,/usr/bin/c++ 与 /usr/bin/g++ 是同一个文件(硬链接)。 FreeBSD 8 附带 (GCC) 4.2.1 20070719
这取决于您使用的编译器/IDE。
使用 Visual Studio ctrl-shift-B 是您构建项目所需的一切。
使用 gcc 在命令行中输入: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. [...]
【讨论】: