Name

gcc

Synopsis

    gcc [options]files

GNU Compiler Collection. gcc, formerly known as the GNU C Compiler, compiles multiple languages (C, C++, Objective-C, Ada, Fortran, and Java) to machine code. Here we document its use to compile C, C++, or Objective-C code. gcc compiles one or more program source files; for example, C source files (file.c), assembler source files (file.s), or preprocessed C source files (file.i). If the file suffix is not recognizable, assume that the file is an object file or library. gcc normally invokes the C preprocessor, compiles the preprocessed code to assembly language code, assembles it, and then links it with the linker. This process can be stopped at one of these stages using the -c, -S, or -E option. The steps may also differ depending on the language being compiled. By default, output is placed in a.out. In some cases, gcc generates an object file having a .o suffix and a corresponding root name.

Preprocessor and linker options given on the gcc command line are passed on to these tools when they are run. These options are briefly described here, but some are more fully described under the entry for ld. The options that follow are divided into general, preprocessor and linker options. We have included only the most generally useful options. gcc accepts many, many more options not covered here.

Tip

gcc is the GNU form of cc; on most Linux systems, the command cc invokes gcc. The command g++ invokes gcc with the appropriate options for interpreting C++; ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.