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.

323 line
15KB

  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>Directory Options (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Directory Options (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Directory Options (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="Invoking-GCC.html#Invoking-GCC" rel="up" title="Invoking GCC">
  30. <link href="Code-Gen-Options.html#Code-Gen-Options" rel="next" title="Code Gen Options">
  31. <link href="Link-Options.html#Link-Options" rel="prev" title="Link Options">
  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="Directory-Options"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Code-Gen-Options.html#Code-Gen-Options" accesskey="n" rel="next">Code Gen Options</a>, Previous: <a href="Link-Options.html#Link-Options" accesskey="p" rel="prev">Link Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</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="Options-for-Directory-Search"></a>
  68. <h3 class="section">3.16 Options for Directory Search</h3>
  69. <a name="index-directory-options"></a>
  70. <a name="index-options_002c-directory-search"></a>
  71. <a name="index-search-path"></a>
  72. <p>These options specify directories to search for header files, for
  73. libraries and for parts of the compiler:
  74. </p>
  75. <dl compact="compact">
  76. <dt><code>-I <var>dir</var></code></dt>
  77. <dt><code>-iquote <var>dir</var></code></dt>
  78. <dt><code>-isystem <var>dir</var></code></dt>
  79. <dt><code>-idirafter <var>dir</var></code></dt>
  80. <dd><a name="index-I"></a>
  81. <a name="index-iquote"></a>
  82. <a name="index-isystem"></a>
  83. <a name="index-idirafter"></a>
  84. <p>Add the directory <var>dir</var> to the list of directories to be searched
  85. for header files during preprocessing.
  86. If <var>dir</var> begins with &lsquo;<samp>=</samp>&rsquo; or <code>$SYSROOT</code>, then the &lsquo;<samp>=</samp>&rsquo;
  87. or <code>$SYSROOT</code> is replaced by the sysroot prefix; see
  88. <samp>--sysroot</samp> and <samp>-isysroot</samp>.
  89. </p>
  90. <p>Directories specified with <samp>-iquote</samp> apply only to the quote
  91. form of the directive, <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>.
  92. Directories specified with <samp>-I</samp>, <samp>-isystem</samp>,
  93. or <samp>-idirafter</samp> apply to lookup for both the
  94. <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code> and
  95. <code>#include&nbsp;&lt;<var>file</var>&gt;<!-- /@w --></code> directives.
  96. </p>
  97. <p>You can specify any number or combination of these options on the
  98. command line to search for header files in several directories.
  99. The lookup order is as follows:
  100. </p>
  101. <ol>
  102. <li> For the quote form of the include directive, the directory of the current
  103. file is searched first.
  104. </li><li> For the quote form of the include directive, the directories specified
  105. by <samp>-iquote</samp> options are searched in left-to-right order,
  106. as they appear on the command line.
  107. </li><li> Directories specified with <samp>-I</samp> options are scanned in
  108. left-to-right order.
  109. </li><li> Directories specified with <samp>-isystem</samp> options are scanned in
  110. left-to-right order.
  111. </li><li> Standard system directories are scanned.
  112. </li><li> Directories specified with <samp>-idirafter</samp> options are scanned in
  113. left-to-right order.
  114. </li></ol>
  115. <p>You can use <samp>-I</samp> to override a system header
  116. file, substituting your own version, since these directories are
  117. searched before the standard system header file directories.
  118. However, you should
  119. not use this option to add directories that contain vendor-supplied
  120. system header files; use <samp>-isystem</samp> for that.
  121. </p>
  122. <p>The <samp>-isystem</samp> and <samp>-idirafter</samp> options also mark the directory
  123. as a system directory, so that it gets the same special treatment that
  124. is applied to the standard system directories.
  125. </p>
  126. <p>If a standard system include directory, or a directory specified with
  127. <samp>-isystem</samp>, is also specified with <samp>-I</samp>, the <samp>-I</samp>
  128. option is ignored. The directory is still searched but as a
  129. system directory at its normal position in the system include chain.
  130. This is to ensure that GCC&rsquo;s procedure to fix buggy system headers and
  131. the ordering for the <code>#include_next</code> directive are not inadvertently
  132. changed.
  133. If you really need to change the search order for system directories,
  134. use the <samp>-nostdinc</samp> and/or <samp>-isystem</samp> options.
  135. </p>
  136. </dd>
  137. <dt><code>-I-</code></dt>
  138. <dd><a name="index-I_002d"></a>
  139. <p>Split the include path.
  140. This option has been deprecated. Please use <samp>-iquote</samp> instead for
  141. <samp>-I</samp> directories before the <samp>-I-</samp> and remove the <samp>-I-</samp>
  142. option.
  143. </p>
  144. <p>Any directories specified with <samp>-I</samp>
  145. options before <samp>-I-</samp> are searched only for headers requested with
  146. <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>; they are not searched for
  147. <code>#include&nbsp;&lt;<var>file</var>&gt;<!-- /@w --></code>. If additional directories are
  148. specified with <samp>-I</samp> options after the <samp>-I-</samp>, those
  149. directories are searched for all &lsquo;<samp>#include</samp>&rsquo; directives.
  150. </p>
  151. <p>In addition, <samp>-I-</samp> inhibits the use of the directory of the current
  152. file directory as the first search directory for <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>. There is no way to override this effect of <samp>-I-</samp>.
  153. </p>
  154. </dd>
  155. <dt><code>-iprefix <var>prefix</var></code></dt>
  156. <dd><a name="index-iprefix"></a>
  157. <p>Specify <var>prefix</var> as the prefix for subsequent <samp>-iwithprefix</samp>
  158. options. If the prefix represents a directory, you should include the
  159. final &lsquo;<samp>/</samp>&rsquo;.
  160. </p>
  161. </dd>
  162. <dt><code>-iwithprefix <var>dir</var></code></dt>
  163. <dt><code>-iwithprefixbefore <var>dir</var></code></dt>
  164. <dd><a name="index-iwithprefix"></a>
  165. <a name="index-iwithprefixbefore"></a>
  166. <p>Append <var>dir</var> to the prefix specified previously with
  167. <samp>-iprefix</samp>, and add the resulting directory to the include search
  168. path. <samp>-iwithprefixbefore</samp> puts it in the same place <samp>-I</samp>
  169. would; <samp>-iwithprefix</samp> puts it where <samp>-idirafter</samp> would.
  170. </p>
  171. </dd>
  172. <dt><code>-isysroot <var>dir</var></code></dt>
  173. <dd><a name="index-isysroot"></a>
  174. <p>This option is like the <samp>--sysroot</samp> option, but applies only to
  175. header files (except for Darwin targets, where it applies to both header
  176. files and libraries). See the <samp>--sysroot</samp> option for more
  177. information.
  178. </p>
  179. </dd>
  180. <dt><code>-imultilib <var>dir</var></code></dt>
  181. <dd><a name="index-imultilib"></a>
  182. <p>Use <var>dir</var> as a subdirectory of the directory containing
  183. target-specific C++ headers.
  184. </p>
  185. </dd>
  186. <dt><code>-nostdinc</code></dt>
  187. <dd><a name="index-nostdinc"></a>
  188. <p>Do not search the standard system directories for header files.
  189. Only the directories explicitly specified with <samp>-I</samp>,
  190. <samp>-iquote</samp>, <samp>-isystem</samp>, and/or <samp>-idirafter</samp>
  191. options (and the directory of the current file, if appropriate)
  192. are searched.
  193. </p>
  194. </dd>
  195. <dt><code>-nostdinc++</code></dt>
  196. <dd><a name="index-nostdinc_002b_002b-1"></a>
  197. <p>Do not search for header files in the C++-specific standard directories,
  198. but do still search the other standard directories. (This option is
  199. used when building the C++ library.)
  200. </p>
  201. </dd>
  202. <dt><code>-iplugindir=<var>dir</var></code></dt>
  203. <dd><a name="index-iplugindir_003d"></a>
  204. <p>Set the directory to search for plugins that are passed
  205. by <samp>-fplugin=<var>name</var></samp> instead of
  206. <samp>-fplugin=<var>path</var>/<var>name</var>.so</samp>. This option is not meant
  207. to be used by the user, but only passed by the driver.
  208. </p>
  209. </dd>
  210. <dt><code>-L<var>dir</var></code></dt>
  211. <dd><a name="index-L"></a>
  212. <p>Add directory <var>dir</var> to the list of directories to be searched
  213. for <samp>-l</samp>.
  214. </p>
  215. </dd>
  216. <dt><code>-B<var>prefix</var></code></dt>
  217. <dd><a name="index-B"></a>
  218. <p>This option specifies where to find the executables, libraries,
  219. include files, and data files of the compiler itself.
  220. </p>
  221. <p>The compiler driver program runs one or more of the subprograms
  222. <code>cpp</code>, <code>cc1</code>, <code>as</code> and <code>ld</code>. It tries
  223. <var>prefix</var> as a prefix for each program it tries to run, both with and
  224. without &lsquo;<samp><var>machine</var>/<var>version</var>/</samp>&rsquo; for the corresponding target
  225. machine and compiler version.
  226. </p>
  227. <p>For each subprogram to be run, the compiler driver first tries the
  228. <samp>-B</samp> prefix, if any. If that name is not found, or if <samp>-B</samp>
  229. is not specified, the driver tries two standard prefixes,
  230. <samp>/usr/lib/gcc/</samp> and <samp>/usr/local/lib/gcc/</samp>. If neither of
  231. those results in a file name that is found, the unmodified program
  232. name is searched for using the directories specified in your
  233. <code>PATH</code> environment variable.
  234. </p>
  235. <p>The compiler checks to see if the path provided by <samp>-B</samp>
  236. refers to a directory, and if necessary it adds a directory
  237. separator character at the end of the path.
  238. </p>
  239. <p><samp>-B</samp> prefixes that effectively specify directory names also apply
  240. to libraries in the linker, because the compiler translates these
  241. options into <samp>-L</samp> options for the linker. They also apply to
  242. include files in the preprocessor, because the compiler translates these
  243. options into <samp>-isystem</samp> options for the preprocessor. In this case,
  244. the compiler appends &lsquo;<samp>include</samp>&rsquo; to the prefix.
  245. </p>
  246. <p>The runtime support file <samp>libgcc.a</samp> can also be searched for using
  247. the <samp>-B</samp> prefix, if needed. If it is not found there, the two
  248. standard prefixes above are tried, and that is all. The file is left
  249. out of the link if it is not found by those means.
  250. </p>
  251. <p>Another way to specify a prefix much like the <samp>-B</samp> prefix is to use
  252. the environment variable <code>GCC_EXEC_PREFIX</code>. See <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>.
  253. </p>
  254. <p>As a special kludge, if the path provided by <samp>-B</samp> is
  255. <samp>[dir/]stage<var>N</var>/</samp>, where <var>N</var> is a number in the range 0 to
  256. 9, then it is replaced by <samp>[dir/]include</samp>. This is to help
  257. with boot-strapping the compiler.
  258. </p>
  259. </dd>
  260. <dt><code>-no-canonical-prefixes</code></dt>
  261. <dd><a name="index-no_002dcanonical_002dprefixes"></a>
  262. <p>Do not expand any symbolic links, resolve references to &lsquo;<samp>/../</samp>&rsquo;
  263. or &lsquo;<samp>/./</samp>&rsquo;, or make the path absolute when generating a relative
  264. prefix.
  265. </p>
  266. </dd>
  267. <dt><code>--sysroot=<var>dir</var></code></dt>
  268. <dd><a name="index-sysroot"></a>
  269. <p>Use <var>dir</var> as the logical root directory for headers and libraries.
  270. For example, if the compiler normally searches for headers in
  271. <samp>/usr/include</samp> and libraries in <samp>/usr/lib</samp>, it instead
  272. searches <samp><var>dir</var>/usr/include</samp> and <samp><var>dir</var>/usr/lib</samp>.
  273. </p>
  274. <p>If you use both this option and the <samp>-isysroot</samp> option, then
  275. the <samp>--sysroot</samp> option applies to libraries, but the
  276. <samp>-isysroot</samp> option applies to header files.
  277. </p>
  278. <p>The GNU linker (beginning with version 2.16) has the necessary support
  279. for this option. If your linker does not support this option, the
  280. header file aspect of <samp>--sysroot</samp> still works, but the
  281. library aspect does not.
  282. </p>
  283. </dd>
  284. <dt><code>--no-sysroot-suffix</code></dt>
  285. <dd><a name="index-no_002dsysroot_002dsuffix"></a>
  286. <p>For some targets, a suffix is added to the root directory specified
  287. with <samp>--sysroot</samp>, depending on the other options used, so that
  288. headers may for example be found in
  289. <samp><var>dir</var>/<var>suffix</var>/usr/include</samp> instead of
  290. <samp><var>dir</var>/usr/include</samp>. This option disables the addition of
  291. such a suffix.
  292. </p>
  293. </dd>
  294. </dl>
  295. <hr>
  296. <div class="header">
  297. <p>
  298. Next: <a href="Code-Gen-Options.html#Code-Gen-Options" accesskey="n" rel="next">Code Gen Options</a>, Previous: <a href="Link-Options.html#Link-Options" accesskey="p" rel="prev">Link Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</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>
  299. </div>
  300. </body>
  301. </html>