1 <section xmlns="http://docbook.org/ns/docbook" version="5.0"
2 xml:id="manual.intro.setup.configure" xreflabel="Configuring">
3 <?dbhtml filename="configure.html"?>
5 <info><title>Configure</title>
7 <keyword>ISO C++</keyword>
8 <keyword>configure</keyword>
9 <keyword>options</keyword>
16 When configuring libstdc++, you'll have to configure the entire
17 <emphasis>gccsrcdir</emphasis> directory. Consider using the
18 toplevel gcc configuration option
19 <literal>--enable-languages=c++</literal>, which saves time by only
20 building the C++ toolchain.
24 Here are all of the configure options specific to libstdc++. Keep
26 <!-- This SECnn should be the "Choosing Package Options" section. -->
27 <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://sourceware.org/autobook/autobook/autobook_14.html">they
28 all have opposite forms as well</link> (enable/disable and
29 with/without). The defaults are for the <emphasis>current
30 development sources</emphasis>, which may be different than those
31 for released versions.
33 <para>The canonical way to find out the configure options that are
34 available for a given set of libstdc++ sources is to go to the
35 source directory and then type: <command>./configure --help</command>.
39 <varlistentry><term><code>--enable-multilib</code>[default]</term>
40 <listitem><para>This is part of the generic multilib support for building cross
41 compilers. As such, targets like "powerpc-elf" will have
42 libstdc++ built many different ways: "-msoft-float"
43 and not, etc. A different libstdc++ will be built for each of
44 the different multilib versions. This option is on by default.
46 </listitem></varlistentry>
48 <varlistentry><term><code>--enable-version-specific-runtime-libs</code></term>
49 <listitem><para>Specify that run-time libraries should be installed in the
50 compiler-specific subdirectory (i.e.,
51 <code>${libdir}/gcc-lib/${target_alias}/${gcc_version}</code>)
52 instead of <code>${libdir}</code>. This option is useful if you
53 intend to use several versions of gcc in parallel. In addition,
54 libstdc++'s include files will be installed in
55 <code>${libdir}/gcc-lib/${target_alias}/${gcc_version}/include/g++</code>,
56 unless you also specify
57 <literal>--with-gxx-include-dir=</literal><filename class="directory">dirname</filename> during configuration.
59 </listitem></varlistentry>
61 <varlistentry><term><code>--with-gxx-include-dir=<include-files dir></code></term>
62 <listitem><para>Adds support for named libstdc++ include directory. For instance,
63 the following puts all the libstdc++ headers into a directory
64 called "4.4-20090404" instead of the usual
68 --with-gxx-include-dir=/foo/H-x86-gcc-3-c-gxx-inc/include/4.4-20090404</programlisting> </listitem></varlistentry>
70 <varlistentry><term><code>--enable-cstdio</code></term>
71 <listitem><para>This is an abbreviated form of <code>'--enable-cstdio=stdio'</code>
74 </listitem></varlistentry>
76 <varlistentry><term><code>--enable-cstdio=OPTION</code></term>
77 <listitem><para>Select a target-specific I/O package. The choices are 'stdio'
78 which is a generic abstraction using POSIX file I/O APIs
79 (<function>read</function>, <function>write</function>,
80 <function>lseek</function>, etc.), and 'stdio_pure' which is similar
81 but only uses standard C file I/O APIs (<function>fread</function>,
82 <function>fwrite</function>, <function>fseek</function>, etc.).
83 The 'stdio_posix' choice is a synonym for 'stdio'.
84 The default is 'stdio'. This option can change the library ABI.
86 </listitem></varlistentry>
88 <varlistentry><term><code>--enable-clocale</code></term>
89 <listitem><para>This is an abbreviated form of <code>'--enable-clocale=generic'</code>
92 </listitem></varlistentry>
94 <varlistentry><term><code>--enable-clocale=OPTION</code></term>
95 <listitem><para>Select a target-specific underlying locale package. The
96 choices are 'ieee_1003.1-2001' to specify an X/Open, Standard Unix
97 (IEEE Std. 1003.1-2001) model based on langinfo/iconv/catgets,
98 'gnu' to specify a model based on functionality from the GNU C
99 library (langinfo/iconv/gettext) (from <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.gnu.org/software/libc/">glibc</link>, the GNU C
100 library), 'generic' to use a generic "C" abstraction which consists
101 of "C" locale info, 'newlib' to specify the Newlib C library model
102 which only differs from the 'generic' model in the handling of
103 ctype, or 'darwin' which omits the <type>wchar_t</type> specializations
104 needed by the 'generic' model.
107 <para>If not explicitly specified, the configure process tries
108 to guess the most suitable package from the choices above. The
109 default is 'generic'. On glibc-based systems of sufficient
110 vintage (2.3 and newer), 'gnu' is automatically selected. On newlib-based
111 systems (<code>'--with_newlib=yes'</code>) and OpenBSD, 'newlib' is
112 automatically selected. On Mac OS X 'darwin' is automatically selected.
113 This option can change the library ABI.
115 </listitem></varlistentry>
117 <varlistentry><term><code>--enable-libstdcxx-allocator</code></term>
118 <listitem><para>This is an abbreviated form of
119 <code>'--enable-libstdcxx-allocator=auto'</code> (described
122 </listitem></varlistentry>
124 <varlistentry><term><code>--enable-libstdcxx-allocator=OPTION </code></term>
125 <listitem><para>Select a target-specific underlying std::allocator. The
126 choices are 'new' to specify a wrapper for new, and 'malloc' to
127 specify a wrapper for malloc.
128 See <xref linkend="allocator.ext"/> for more information.
129 This option can change the library ABI.
131 </listitem></varlistentry>
133 <varlistentry><term><code>--enable-cheaders=OPTION</code></term>
134 <listitem><para>This allows the user to define the approach taken for C header
135 compatibility with C++. Options are c, c_std, and c_global.
136 These correspond to the source directory's include/c,
137 include/c_std, and include/c_global, and may also include
138 include/c_compatibility. The default is 'c_global'.
140 </listitem></varlistentry>
142 <varlistentry><term><code>--enable-threads</code></term>
143 <listitem><para>This is an abbreviated form of <code>'--enable-threads=yes'</code>
146 </listitem></varlistentry>
148 <varlistentry><term><code>--enable-threads=OPTION</code></term>
149 <listitem><para>Select a threading library. A full description is
151 general <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/install/configure.html">compiler
152 configuration instructions</link>. This option can change the
155 </listitem></varlistentry>
157 <varlistentry><term><code>--enable-libstdcxx-threads</code></term>
158 <listitem><para>Enable C++11 threads support. If not explicitly specified,
159 the configure process enables it if possible. This
160 option can change the library ABI.
162 </listitem></varlistentry>
164 <varlistentry><term><code>--enable-libstdcxx-time</code></term>
165 <listitem><para>This is an abbreviated form of
166 <code>'--enable-libstdcxx-time=yes'</code>(described next).
168 </listitem></varlistentry>
170 <varlistentry><term><code>--enable-libstdcxx-time=OPTION</code></term>
171 <listitem><para>Enables link-type checks for the availability of the
172 <function>clock_gettime</function> clocks, used in the implementation
173 of [time.clock], and of the <function>nanosleep</function> and
174 <function>sched_yield</function> functions, used in the
175 implementation of [thread.thread.this] of the 2011 ISO C++ standard.
176 The choice OPTION=yes checks for the availability of the facilities
177 in libc. OPTION=rt also checks in
178 librt (and, if it's needed, links to it). Note that linking to librt
179 is not always desirable because for glibc it requires linking to
180 libpthread too, which causes all reference counting to use atomic
181 operations, resulting in a potentially large overhead for
182 single-threaded programs. OPTION=no skips the tests completely.
183 The default is OPTION=auto, which skips the checks and enables the
184 features only for targets known to support them.
185 For Linux targets, if <function>clock_gettime</function> is not used
186 then the [time.clock] implementation will use a system call to access
187 the realtime and monotonic clocks, which is significantly slower than
188 the C library's <function>clock_gettime</function> function.
190 </listitem></varlistentry>
192 <varlistentry><term><code>--enable-libstdcxx-debug</code></term>
193 <listitem><para>Build separate debug libraries in addition to what is normally built.
194 By default, the debug libraries are compiled with
195 <code> CXXFLAGS='-g3 -O0 -fno-inline'</code>
196 , are installed in <code>${libdir}/debug</code>, and have the
197 same names and versioning information as the non-debug
198 libraries. This option is off by default.
200 <para>Note this make command, executed in
201 the build directory, will do much the same thing, without the
202 configuration difference and without building everything twice:
203 <code>make CXXFLAGS='-g3 -O0 -fno-inline' all</code>
205 </listitem></varlistentry>
207 <varlistentry><term><code>--enable-libstdcxx-debug-flags=FLAGS</code></term>
209 <listitem><para>This option is only valid when
210 <code>--enable-libstdcxx-debug</code>
211 is also specified, and applies to the debug builds only. With
212 this option, you can pass a specific string of flags to the
213 compiler to use when building the debug versions of libstdc++.
214 FLAGS is a quoted string of options, like
217 --enable-libstdcxx-debug-flags='-g3 -O1 -fno-inline'</programlisting>
218 </listitem></varlistentry>
220 <varlistentry><term><code>--enable-cxx-flags=FLAGS</code></term>
221 <listitem><para>With this option, you can pass a string of -f (functionality)
222 flags to the compiler to use when building libstdc++. This
223 option can change the library ABI. FLAGS is a quoted string of
227 --enable-cxx-flags='-fvtable-gc -fomit-frame-pointer -ansi'</programlisting>
229 Note that the flags don't necessarily have to all be -f flags,
230 as shown, but usually those are the ones that will make sense
231 for experimentation and configure-time overriding.
233 <para>The advantage of --enable-cxx-flags over setting CXXFLAGS in
234 the 'make' environment is that, if files are automatically
235 rebuilt, the same flags will be used when compiling those files
236 as well, so that everything matches.
238 <para>Fun flags to try might include combinations of
244 -fvtable-gc</programlisting>
245 <para>and opposite forms (-fno-) of the same. Tell us (the libstdc++
246 mailing list) if you discover more!
248 </listitem></varlistentry>
250 <varlistentry><term><code>--enable-c99</code></term>
251 <listitem><para>The <type>long long</type> type was introduced in C99, along
252 with many other functions for wide characters, and math
253 classification macros, etc. If enabled, all C99 functions not
254 specified by the C++ standard will be put into <code>namespace
255 __gnu_cxx</code>, and then all these names will
256 be injected into namespace std, so that C99 functions can be
257 used "as if" they were in the C++ standard (as they
258 will eventually be in some future revision of the standard,
259 without a doubt). By default, C99 support is on, assuming the
260 configure probes find all the necessary functions and bits
261 necessary. This option can change the library ABI.
263 </listitem></varlistentry>
265 <varlistentry><term><code>--enable-wchar_t</code>[default]</term>
266 <listitem><para>Template specializations for the <type>wchar_t</type> type are
267 required for wide character conversion support. Disabling
268 wide character specializations may be expedient for initial
269 porting efforts, but builds only a subset of what is required by
270 ISO, and is not recommended. By default, this option is on.
271 This option can change the library ABI.
273 </listitem></varlistentry>
275 <varlistentry><term><code>--enable-long-long </code></term>
276 <listitem><para>The <type>long long</type> type was introduced in C99. It is
277 provided as a GNU extension to C++98 in g++. This flag builds
278 support for "long long" into the library (specialized
279 templates and the like for iostreams). This option is on by default:
280 if enabled, users will have to either use the new-style "C"
281 headers by default (i.e., <cmath> not <math.h>)
282 or add appropriate compile-time flags to all compile lines to
283 allow "C" visibility of this feature (on GNU/Linux,
284 the flag is -D_ISOC99_SOURCE, which is added automatically via
285 CPLUSPLUS_CPP_SPEC's addition of _GNU_SOURCE).
286 This option can change the library ABI.
288 </listitem></varlistentry>
290 <varlistentry><term><code>--enable-fully-dynamic-string</code></term>
291 <listitem><para>This option enables a special version of basic_string avoiding
292 the optimization that allocates empty objects in static memory.
293 Mostly useful together with shared memory allocators, see PR
294 libstdc++/16612 for details.
296 </listitem></varlistentry>
298 <varlistentry><term><code>--enable-concept-checks</code></term>
299 <listitem><para>This turns on additional compile-time checks for instantiated
300 library templates, in the form of specialized templates described in
301 the <link linkend="std.diagnostics.concept_checking">Concept
302 Checking</link> section. They
303 can help users discover when they break the rules of the STL, before
304 their programs run. These checks are based on C++03 rules and some of
305 them are not compatible with correct C++11 code.
307 </listitem></varlistentry>
309 <varlistentry><term><code>--enable-symvers[=style]</code></term>
311 <listitem><para>In 3.1 and later, tries to turn on symbol versioning in the
312 shared library (if a shared library has been
313 requested). Values for 'style' that are currently supported
314 are 'gnu', 'gnu-versioned-namespace', 'darwin',
315 'darwin-export', and 'sun'. Both gnu- options require that a recent
316 version of the GNU linker be in use. Both darwin options are
317 equivalent. With no style given, the configure script will try
318 to guess correct defaults for the host system, probe to see if
319 additional requirements are necessary and present for
320 activation, and if so, will turn symbol versioning on. This
321 option can change the library ABI.
324 </listitem></varlistentry>
326 <varlistentry><term><code>--enable-libstdcxx-visibility</code></term>
327 <listitem><para> In 4.2 and later, enables or disables visibility
328 attributes. If enabled (as by default), and the compiler seems
329 capable of passing the simple sanity checks thrown at it, adjusts
330 items in namespace std, namespace std::tr1, namespace std::tr2,
331 and namespace __gnu_cxx to have <code>visibility ("default")</code>
332 so that -fvisibility options can be used without affecting the
333 normal external-visibility of namespace std entities.
334 Prior to 4.7 this option was spelled <code>--enable-visibility</code>.
336 </listitem></varlistentry>
338 <varlistentry><term><code>--enable-libstdcxx-pch</code></term>
339 <listitem><para>In 3.4 and later, tries to turn on the generation of
340 stdc++.h.gch, a pre-compiled file including all the standard
341 C++ includes. If enabled (as by default), and the compiler
342 seems capable of passing the simple sanity checks thrown at
343 it, try to build stdc++.h.gch as part of the make process.
344 In addition, this generated file is used later on (by appending
345 <code>-include bits/stdc++.h</code> to CXXFLAGS) when running the
348 </listitem></varlistentry>
351 <varlistentry><term><code>--enable-extern-template</code>[default]</term>
352 <listitem><para>Use extern template to pre-instantiate all required
353 specializations for certain types defined in the standard libraries.
354 These types include <classname>string</classname> and dependents like
355 <classname>char_traits</classname>, the templatized IO classes,
356 <classname>allocator</classname>, and others.
357 Disabling means that implicit
358 template generation will be used when compiling these types. By
359 default, this option is on. This option can change the library ABI.
361 </listitem></varlistentry>
363 <varlistentry><term><code>--disable-hosted-libstdcxx</code></term>
366 By default, a complete <emphasis>hosted</emphasis> C++ library is
367 built. The C++ Standard also describes a
368 <emphasis>freestanding</emphasis> environment, in which only a
369 minimal set of headers are provided. This option builds such an
370 environment. Note that a hosted library installs headers that still can
371 be used in non hosted environments, as the library checks for
372 <code>__STDC_HOSTED__</code>, however, a library configured with
373 <code>--disable-hosted-libstdcxx</code> will not install unusable headers.
375 </listitem></varlistentry>
377 <varlistentry><term><code>--disable-libstdcxx-hosted</code></term>
379 <para>This is an alias for <code>--disable-hosted-libstdcxx</code>.</para>
380 </listitem></varlistentry>
382 <varlistentry><term><code>--disable-libstdcxx-verbose</code></term>
385 By default, the library is configured to write descriptive messages
386 to standard error for certain events such as calling a pure virtual
387 function or the invocation of the standard terminate handler. Those
388 messages cause the library to depend on the demangler and standard I/O
389 facilities, which might be undesirable in a low-memory environment or
390 when standard error is not available. This option disables those
391 messages. This option does not change the library ABI.
393 </listitem></varlistentry>
395 <varlistentry><term><code>--disable-libstdcxx-dual-abi</code></term>
398 Disable support for the new, C++11-conforming implementations of
399 <code>std::string</code>, <code>std::list</code> etc. so that the
400 library only provides definitions of types using the old ABI
401 (see <xref linkend="manual.intro.using.abi"/>).
402 This option changes the library ABI.
404 </listitem></varlistentry>
406 <varlistentry><term><code>--with-default-libstdcxx-abi=</code><replaceable>OPTION</replaceable></term>
409 Set the default value for the <symbol>_GLIBCXX_USE_CXX11_ABI</symbol>
410 macro (see <xref linkend="manual.intro.using.macros"/>).
411 The default is <option>OPTION=new</option> which sets the macro to
412 <literal>1</literal>,
413 use <option>OPTION=gcc4-compatible</option> to set it to
414 <literal>0</literal>.
415 This option does not change the library ABI.
417 </listitem></varlistentry>
419 <varlistentry><term><code>--with-libstdcxx-lock-policy=OPTION</code></term>
420 <listitem><para>Sets the lock policy that controls how
421 <classname>shared_ptr</classname> reference counting is
423 The choice OPTION=atomic enables use of atomics for updates to
424 <classname>shared_ptr</classname> reference counts.
425 The choice OPTION=mutex enables use of a mutex to synchronize updates
426 to <classname>shared_ptr</classname> reference counts.
427 If the compiler's thread model is "single" then this option has no
428 effect, as no synchronization is used for the reference counts.
429 The default is OPTION=auto, which checks for the availability of
430 compiler built-ins for 2-byte and 4-byte atomic compare-and-swap,
431 and uses OPTION=atomic if they're available, OPTION=mutex otherwise.
432 This option can change the library ABI.
433 If the library is configured to use atomics and user programs are
434 compiled using a target that doesn't natively support the atomic
435 operations (e.g. the library is configured for armv7 and then code
436 is compiled with <option>-march=armv5t</option>) then the program
437 might rely on support in libgcc to provide the atomics.
439 </listitem></varlistentry>
441 <varlistentry><term><code>--enable-vtable-verify</code>[default]</term>
443 <para>Use <code>-fvtable-verify=std</code> to compile the C++
444 runtime with instrumentation for vtable verification. All virtual
445 functions in the standard library will be verified at runtime.
446 Types impacted include <classname>locale</classname> and
447 <classname>iostream</classname>, and others. Disabling means that
448 the C++ runtime is compiled without support for vtable
449 verification. By default, this option is off.
451 </listitem></varlistentry>
453 <varlistentry><term><code>--enable-libstdcxx-filesystem-ts</code>[default]</term>
455 <para>Build <filename class="libraryfile">libstdc++fs.a</filename> as well
456 as the usual libstdc++ and libsupc++ libraries. This is enabled by
457 default on select POSIX targets where it is known to work and disabled
460 </listitem></varlistentry>
462 <varlistentry><term><code>--enable-libstdcxx-static-eh-pool</code></term>
464 <para>Use a fixed-size static buffer for the emergency exception handling
465 pool (see <xref linkend="intro.using.exception.alloc"/>). The default
466 is to allocate the pool on program startup using <code>malloc</code>.
467 With this option, a static buffer will be provided by libstdc++ instead.
468 This does not change the library ABI.
470 </listitem></varlistentry>
472 <varlistentry><term><code>--with-libstdcxx-eh-pool-obj-count=NUM</code></term>
474 <para>Set the size of the emergency exception handling pool. NUM is the
475 number of simultaneous allocated exceptions to support.
476 This does not change the library ABI.
478 </listitem></varlistentry>
480 <varlistentry><term><code>--with-libstdcxx-zoneinfo=OPTION</code></term>
482 <para>Choose how <classname>std::chrono::tzdb</classname> will obtain
483 the time zone info. The library requires a copy of the
484 <filename>tzdata.zi</filename> and <filename>leapseconds</filename>
485 files from the <link xmlns:xlink="http://www.w3.org/1999/xlink"
486 xlink:href="https://www.iana.org/time-zones">IANA Time Zone
487 Database</link>. The choice OPTION=static will embed a copy of the files
488 into the library, and use that static data when time zone information
489 is required. The choice OPTION=dir will use the files
490 <filename>dir/tzdata.zi</filename> and
491 <filename>dir/leapseconds</filename> (which must exist when a program
492 tries to access time zone information). The choice OPTION=dir,static
493 will try to use files in <filename>dir</filename> but if they are
494 not available the embedded static data will be used instead.
495 The default choice is OPTION=yes. This is equivalent to OPTION=dir,static
496 with a system-specific default directory (if a suitable default for
497 the target is known).
498 The choice OPTION=no will disable all code for loading time zone info
499 from file or from the embedded static data, which means that only the
500 "UTC" and "GMT" time zones are defined. Using OPTION=no results in a
501 smaller library, so is suitable for systems that will never need to
502 query the time zone database.
503 This does not change the library ABI.
505 </listitem></varlistentry>