1<html lang="en"> 2<head> 3<title>Invoking GCC - Using the GNU Compiler Collection (GCC)</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using the GNU Compiler Collection (GCC)"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="prev" href="Standards.html#Standards" title="Standards"> 9<link rel="next" href="C-Implementation.html#C-Implementation" title="C Implementation"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 131998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 142010 Free Software Foundation, Inc. 15 16Permission is granted to copy, distribute and/or modify this document 17under the terms of the GNU Free Documentation License, Version 1.3 or 18any later version published by the Free Software Foundation; with the 19Invariant Sections being ``Funding Free Software'', the Front-Cover 20Texts being (a) (see below), and with the Back-Cover Texts being (b) 21(see below). A copy of the license is included in the section entitled 22``GNU Free Documentation License''. 23 24(a) The FSF's Front-Cover Text is: 25 26 A GNU Manual 27 28(b) The FSF's Back-Cover Text is: 29 30 You have freedom to copy and modify this GNU Manual, like GNU 31 software. Copies published by the Free Software Foundation raise 32 funds for GNU development.--> 33<meta http-equiv="Content-Style-Type" content="text/css"> 34<style type="text/css"><!-- 35 pre.display { font-family:inherit } 36 pre.format { font-family:inherit } 37 pre.smalldisplay { font-family:inherit; font-size:smaller } 38 pre.smallformat { font-family:inherit; font-size:smaller } 39 pre.smallexample { font-size:smaller } 40 pre.smalllisp { font-size:smaller } 41 span.sc { font-variant:small-caps } 42 span.roman { font-family:serif; font-weight:normal; } 43 span.sansserif { font-family:sans-serif; font-weight:normal; } 44--></style> 45<link rel="stylesheet" type="text/css" href="../cs.css"> 46</head> 47<body> 48<div class="node"> 49<a name="Invoking-GCC"></a> 50<p> 51Next: <a rel="next" accesskey="n" href="C-Implementation.html#C-Implementation">C Implementation</a>, 52Previous: <a rel="previous" accesskey="p" href="Standards.html#Standards">Standards</a>, 53Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> 54<hr> 55</div> 56 57<h2 class="chapter">3 GCC Command Options</h2> 58 59<p><a name="index-GCC-command-options-65"></a><a name="index-command-options-66"></a><a name="index-options_002c-GCC-command-67"></a> 60<!-- man begin DESCRIPTION --> 61When you invoke GCC, it normally does preprocessing, compilation, 62assembly and linking. The “overall options” allow you to stop this 63process at an intermediate stage. For example, the <samp><span class="option">-c</span></samp> option 64says not to run the linker. Then the output consists of object files 65output by the assembler. 66 67 <p>Other options are passed on to one stage of processing. Some options 68control the preprocessor and others the compiler itself. Yet other 69options control the assembler and linker; most of these are not 70documented here, since you rarely need to use any of them. 71 72 <p><a name="index-C-compilation-options-68"></a>Most of the command line options that you can use with GCC are useful 73for C programs; when an option is only useful with another language 74(usually C++), the explanation says so explicitly. If the description 75for a particular option does not mention a source language, you can use 76that option with all supported languages. 77 78 <p><a name="index-C_002b_002b-compilation-options-69"></a>See <a href="Invoking-G_002b_002b.html#Invoking-G_002b_002b">Compiling C++ Programs</a>, for a summary of special 79options for compiling C++ programs. 80 81 <p><a name="index-grouping-options-70"></a><a name="index-options_002c-grouping-71"></a>The <samp><span class="command">gcc</span></samp> program accepts options and file names as operands. Many 82options have multi-letter names; therefore multiple single-letter options 83may <em>not</em> be grouped: <samp><span class="option">-dv</span></samp> is very different from ‘<samp><span class="samp">-d -v</span></samp>’<!-- /@w -->. 84 85 <p><a name="index-order-of-options-72"></a><a name="index-options_002c-order-73"></a>You can mix options and other arguments. For the most part, the order 86you use doesn't matter. Order does matter when you use several 87options of the same kind; for example, if you specify <samp><span class="option">-L</span></samp> more 88than once, the directories are searched in the order specified. Also, 89the placement of the <samp><span class="option">-l</span></samp> option is significant. 90 91 <p>Many options have long names starting with ‘<samp><span class="samp">-f</span></samp>’ or with 92‘<samp><span class="samp">-W</span></samp>’—for example, 93<samp><span class="option">-fmove-loop-invariants</span></samp>, <samp><span class="option">-Wformat</span></samp> and so on. Most of 94these have both positive and negative forms; the negative form of 95<samp><span class="option">-ffoo</span></samp> would be <samp><span class="option">-fno-foo</span></samp>. This manual documents 96only one of these two forms, whichever one is not the default. 97 98<!-- man end --> 99 <p>See <a href="Option-Index.html#Option-Index">Option Index</a>, for an index to GCC's options. 100 101<ul class="menu"> 102<li><a accesskey="1" href="Option-Summary.html#Option-Summary">Option Summary</a>: Brief list of all options, without explanations. 103<li><a accesskey="2" href="Overall-Options.html#Overall-Options">Overall Options</a>: Controlling the kind of output: 104 an executable, object files, assembler files, 105 or preprocessed source. 106<li><a accesskey="3" href="Invoking-G_002b_002b.html#Invoking-G_002b_002b">Invoking G++</a>: Compiling C++ programs. 107<li><a accesskey="4" href="C-Dialect-Options.html#C-Dialect-Options">C Dialect Options</a>: Controlling the variant of C language compiled. 108<li><a accesskey="5" href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">C++ Dialect Options</a>: Variations on C++. 109<li><a accesskey="6" href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options">Objective-C and Objective-C++ Dialect Options</a>: Variations on Objective-C 110 and Objective-C++. 111<li><a accesskey="7" href="Language-Independent-Options.html#Language-Independent-Options">Language Independent Options</a>: Controlling how diagnostics should be 112 formatted. 113<li><a accesskey="8" href="Warning-Options.html#Warning-Options">Warning Options</a>: How picky should the compiler be? 114<li><a accesskey="9" href="Debugging-Options.html#Debugging-Options">Debugging Options</a>: Symbol tables, measurements, and debugging dumps. 115<li><a href="Optimize-Options.html#Optimize-Options">Optimize Options</a>: How much optimization? 116<li><a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>: Controlling header files and macro definitions. 117 Also, getting dependency information for Make. 118<li><a href="Assembler-Options.html#Assembler-Options">Assembler Options</a>: Passing options to the assembler. 119<li><a href="Link-Options.html#Link-Options">Link Options</a>: Specifying libraries and so on. 120<li><a href="Directory-Options.html#Directory-Options">Directory Options</a>: Where to find header files and libraries. 121 Where to find the compiler executable files. 122<li><a href="Spec-Files.html#Spec-Files">Spec Files</a>: How to pass switches to sub-processes. 123<li><a href="Target-Options.html#Target-Options">Target Options</a>: Running a cross-compiler, or an old version of GCC. 124<li><a href="Submodel-Options.html#Submodel-Options">Submodel Options</a>: Specifying minor hardware or convention variations, 125 such as 68010 vs 68020. 126<li><a href="Code-Gen-Options.html#Code-Gen-Options">Code Gen Options</a>: Specifying conventions for function calls, data layout 127 and register usage. 128<li><a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>: Env vars that affect GCC. 129<li><a href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>: Compiling a header once, and using it many times. 130</ul> 131 132<!-- man begin OPTIONS --> 133 </body></html> 134 135