You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
14KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Invoking GCC (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Invoking GCC (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Invoking GCC (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="index.html#Top" rel="up" title="Top">
  30. <link href="Option-Summary.html#Option-Summary" rel="next" title="Option Summary">
  31. <link href="Standards.html#Standards" rel="prev" title="Standards">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Invoking-GCC"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="C-Implementation.html#C-Implementation" accesskey="n" rel="next">C Implementation</a>, Previous: <a href="Standards.html#Standards" accesskey="p" rel="prev">Standards</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="GCC-Command-Options"></a>
  68. <h2 class="chapter">3 GCC Command Options</h2>
  69. <a name="index-GCC-command-options"></a>
  70. <a name="index-command-options"></a>
  71. <a name="index-options_002c-GCC-command"></a>
  72. <p>When you invoke GCC, it normally does preprocessing, compilation,
  73. assembly and linking. The &ldquo;overall options&rdquo; allow you to stop this
  74. process at an intermediate stage. For example, the <samp>-c</samp> option
  75. says not to run the linker. Then the output consists of object files
  76. output by the assembler.
  77. See <a href="Overall-Options.html#Overall-Options">Options Controlling the Kind of Output</a>.
  78. </p>
  79. <p>Other options are passed on to one or more stages of processing. Some options
  80. control the preprocessor and others the compiler itself. Yet other
  81. options control the assembler and linker; most of these are not
  82. documented here, since you rarely need to use any of them.
  83. </p>
  84. <a name="index-C-compilation-options"></a>
  85. <p>Most of the command-line options that you can use with GCC are useful
  86. for C programs; when an option is only useful with another language
  87. (usually C++), the explanation says so explicitly. If the description
  88. for a particular option does not mention a source language, you can use
  89. that option with all supported languages.
  90. </p>
  91. <a name="index-cross-compiling"></a>
  92. <a name="index-specifying-machine-version"></a>
  93. <a name="index-specifying-compiler-version-and-target-machine"></a>
  94. <a name="index-compiler-version_002c-specifying"></a>
  95. <a name="index-target-machine_002c-specifying"></a>
  96. <p>The usual way to run GCC is to run the executable called <code>gcc</code>, or
  97. <code><var>machine</var>-gcc</code> when cross-compiling, or
  98. <code><var>machine</var>-gcc-<var>version</var></code> to run a specific version of GCC.
  99. When you compile C++ programs, you should invoke GCC as <code>g++</code>
  100. instead. See <a href="Invoking-G_002b_002b.html#Invoking-G_002b_002b">Compiling C++ Programs</a>,
  101. for information about the differences in behavior between <code>gcc</code>
  102. and <code>g++</code> when compiling C++ programs.
  103. </p>
  104. <a name="index-grouping-options"></a>
  105. <a name="index-options_002c-grouping"></a>
  106. <p>The <code>gcc</code> program accepts options and file names as operands. Many
  107. options have multi-letter names; therefore multiple single-letter options
  108. may <em>not</em> be grouped: <samp>-dv</samp> is very different from &lsquo;<samp><span class="nolinebreak">-d</span>&nbsp;<span class="nolinebreak">-v</span></samp>&rsquo;<!-- /@w -->.
  109. </p>
  110. <a name="index-order-of-options"></a>
  111. <a name="index-options_002c-order"></a>
  112. <p>You can mix options and other arguments. For the most part, the order
  113. you use doesn&rsquo;t matter. Order does matter when you use several
  114. options of the same kind; for example, if you specify <samp>-L</samp> more
  115. than once, the directories are searched in the order specified. Also,
  116. the placement of the <samp>-l</samp> option is significant.
  117. </p>
  118. <p>Many options have long names starting with &lsquo;<samp>-f</samp>&rsquo; or with
  119. &lsquo;<samp>-W</samp>&rsquo;&mdash;for example,
  120. <samp>-fmove-loop-invariants</samp>, <samp>-Wformat</samp> and so on. Most of
  121. these have both positive and negative forms; the negative form of
  122. <samp>-ffoo</samp> is <samp>-fno-foo</samp>. This manual documents
  123. only one of these two forms, whichever one is not the default.
  124. </p>
  125. <p>Some options take one or more arguments typically separated either
  126. by a space or by the equals sign (&lsquo;<samp>=</samp>&rsquo;) from the option name.
  127. Unless documented otherwise, an argument can be either numeric or
  128. a string. Numeric arguments must typically be small unsigned decimal
  129. or hexadecimal integers. Hexadecimal arguments must begin with
  130. the &lsquo;<samp>0x</samp>&rsquo; prefix. Arguments to options that specify a size
  131. threshold of some sort may be arbitrarily large decimal or hexadecimal
  132. integers followed by a byte size suffix designating a multiple of bytes
  133. such as <code>kB</code> and <code>KiB</code> for kilobyte and kibibyte, respectively,
  134. <code>MB</code> and <code>MiB</code> for megabyte and mebibyte, <code>GB</code> and
  135. <code>GiB</code> for gigabyte and gigibyte, and so on. Such arguments are
  136. designated by <var>byte-size</var> in the following text. Refer to the NIST,
  137. IEC, and other relevant national and international standards for the full
  138. listing and explanation of the binary and decimal byte size prefixes.
  139. </p>
  140. <p>See <a href="Option-Index.html#Option-Index">Option Index</a>, for an index to GCC&rsquo;s options.
  141. </p>
  142. <table class="menu" border="0" cellspacing="0">
  143. <tr><td align="left" valign="top">&bull; <a href="Option-Summary.html#Option-Summary" accesskey="1">Option Summary</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Brief list of all options, without explanations.
  144. </td></tr>
  145. <tr><td align="left" valign="top">&bull; <a href="Overall-Options.html#Overall-Options" accesskey="2">Overall Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Controlling the kind of output:
  146. an executable, object files, assembler files,
  147. or preprocessed source.
  148. </td></tr>
  149. <tr><td align="left" valign="top">&bull; <a href="Invoking-G_002b_002b.html#Invoking-G_002b_002b" accesskey="3">Invoking G++</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Compiling C++ programs.
  150. </td></tr>
  151. <tr><td align="left" valign="top">&bull; <a href="C-Dialect-Options.html#C-Dialect-Options" accesskey="4">C Dialect Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Controlling the variant of C language compiled.
  152. </td></tr>
  153. <tr><td align="left" valign="top">&bull; <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" accesskey="5">C++ Dialect Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Variations on C++.
  154. </td></tr>
  155. <tr><td align="left" valign="top">&bull; <a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" accesskey="6">Objective-C and Objective-C++ Dialect Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Variations on Objective-C
  156. and Objective-C++.
  157. </td></tr>
  158. <tr><td align="left" valign="top">&bull; <a href="Diagnostic-Message-Formatting-Options.html#Diagnostic-Message-Formatting-Options" accesskey="7">Diagnostic Message Formatting Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Controlling how diagnostics should
  159. be formatted.
  160. </td></tr>
  161. <tr><td align="left" valign="top">&bull; <a href="Warning-Options.html#Warning-Options" accesskey="8">Warning Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How picky should the compiler be?
  162. </td></tr>
  163. <tr><td align="left" valign="top">&bull; <a href="Static-Analyzer-Options.html#Static-Analyzer-Options" accesskey="9">Static Analyzer Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">More expensive warnings.
  164. </td></tr>
  165. <tr><td align="left" valign="top">&bull; <a href="Debugging-Options.html#Debugging-Options">Debugging Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Producing debuggable code.
  166. </td></tr>
  167. <tr><td align="left" valign="top">&bull; <a href="Optimize-Options.html#Optimize-Options">Optimize Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How much optimization?
  168. </td></tr>
  169. <tr><td align="left" valign="top">&bull; <a href="Instrumentation-Options.html#Instrumentation-Options">Instrumentation Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Enabling profiling and extra run-time error checking.
  170. </td></tr>
  171. <tr><td align="left" valign="top">&bull; <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Controlling header files and macro definitions.
  172. Also, getting dependency information for Make.
  173. </td></tr>
  174. <tr><td align="left" valign="top">&bull; <a href="Assembler-Options.html#Assembler-Options">Assembler Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Passing options to the assembler.
  175. </td></tr>
  176. <tr><td align="left" valign="top">&bull; <a href="Link-Options.html#Link-Options">Link Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying libraries and so on.
  177. </td></tr>
  178. <tr><td align="left" valign="top">&bull; <a href="Directory-Options.html#Directory-Options">Directory Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Where to find header files and libraries.
  179. Where to find the compiler executable files.
  180. </td></tr>
  181. <tr><td align="left" valign="top">&bull; <a href="Code-Gen-Options.html#Code-Gen-Options">Code Gen Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying conventions for function calls, data layout
  182. and register usage.
  183. </td></tr>
  184. <tr><td align="left" valign="top">&bull; <a href="Developer-Options.html#Developer-Options">Developer Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Printing GCC configuration info, statistics, and
  185. debugging dumps.
  186. </td></tr>
  187. <tr><td align="left" valign="top">&bull; <a href="Submodel-Options.html#Submodel-Options">Submodel Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Target-specific options, such as compiling for a
  188. specific processor variant.
  189. </td></tr>
  190. <tr><td align="left" valign="top">&bull; <a href="Spec-Files.html#Spec-Files">Spec Files</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to pass switches to sub-processes.
  191. </td></tr>
  192. <tr><td align="left" valign="top">&bull; <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Env vars that affect GCC.
  193. </td></tr>
  194. <tr><td align="left" valign="top">&bull; <a href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Compiling a header once, and using it many times.
  195. </td></tr>
  196. </table>
  197. <hr>
  198. <div class="header">
  199. <p>
  200. Next: <a href="C-Implementation.html#C-Implementation" accesskey="n" rel="next">C Implementation</a>, Previous: <a href="Standards.html#Standards" accesskey="p" rel="prev">Standards</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  201. </div>
  202. </body>
  203. </html>