2010-01-03 58 views

回答

5

报价http://users.actcom.co.il/~choo/lupg/tutorials/c-on-unix/c-on-unix.html

编译最简单的情况是,当你在一个single file设置的所有源代码。

cc single_main.c 

你会抱怨“的a.out”是一个过于笼统的名称(如它从何而来呢? - 好,这是一个历史名称,由于一些所谓的使用“一.out格式“用于旧版Unix系统上编译的程序)。假设你想把结果程序称为“single_main”。在这种情况下,你可以使用以下行来编译:

cc single_main.c -o single_main 
+0

“cc”?我们是在五十年代吗? – 2010-01-03 13:46:36

+4

好吧,现在它通常会是一个符号链接,我猜... FreeBSD上的 – miku 2010-01-03 13:48:35

+1

,'/ usr/bin/cc'与'/ usr/bin/gcc'和'/ usr/bin/C++'与'/ usr/bin/g ++'(硬链接)文件相同。 FreeBSD 8附带'(GCC)4.2.1 20070719' – 2010-01-03 18:08:58

4

这取决于什么编译器/ IDE使用。

随着Visual Studio ctrl-shift-B是你所需要建立你的项目。

使用gcc在命令行输入:gcc file.c -o executable_name

2
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. [...]