1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
4 <META NAME="AUTHOR" CONTENT="pme@sources.redhat.com (Phil Edwards)">
5 <META NAME="KEYWORDS" CONTENT="libstdc++, libstdc++-v3, GCC, g++">
6 <META NAME="DESCRIPTION" CONTENT="README for the GNU libstdc++ effort.">
7 <META NAME="GENERATOR" CONTENT="vi and eight fingers">
8 <TITLE>libstdc++-v3 Installation Instructions</TITLE>
9 <LINK REL=StyleSheet HREF="lib3styles.css">
10 <!-- $Id: install.html,v 1.12 2000/12/03 23:47:47 jsm28 Exp $ -->
14 <H1 CLASS="centered"><A NAME="top">libstdc++-v3 INSTALL</A></H1>
16 <P>The latest version of this document is always available at
17 <A HREF="http://gcc.gnu.org/onlinedocs/libstdc++/install.html">
18 http://gcc.gnu.org/onlinedocs/libstdc++/install.html</A>.
21 <P>To the <A HREF="http://gcc.gnu.org/libstdc++/">libstdc++-v3 homepage</A>.
24 <!-- ####################################################### -->
28 <LI><A HREF="#prereqs">Tools you will need beforehand</A>
29 <LI><A HREF="#srcsetup">Setting up the source directories</A>
30 <LI><A HREF="#config">Configuring</A>
31 <LI><A HREF="#install">Building and installing the library</A>
32 <LI><A HREF="#postinstall">Post-installation</A>
33 <LI><A HREF="#usage">Using the library</A>
38 <!-- ####################################################### -->
40 <H2><A NAME="prereqs">Tools you will need beforehand</A></H2>
41 <P>You will need a recent version of g++ to compile the snapshot of
42 libstdc++: gcc-2.95.2 works well, or one of the post-2.95.2 GCC
43 snapshots (insert standard caveat about using snapshots rather
44 than formal releases). You will need the full source
45 distribution to whatever compiler release you are using. The
46 GCC snapshots can be had from one of the sites on their
47 <A HREF="http://gcc.gnu.org/mirrors.html">mirror list</A>.
50 <P>In addition, if you plan to modify the makefiles or regenerate
51 the configure scripts you'll need the nuevo automake, libtool
52 and autoconf to regenerate the Makefiles and configure
53 scripts. These tools are all required to be installed in the
54 same location (most linux distributions install these tools by
55 default, so no worries.)
58 <P>If you don't have bash, and want to run <TT>'make check'</TT> to
59 test your build, you'll need to get bash 2.x. Also recommended
60 is GNU Make, since it is the only 'make' that will parse these
64 <P>As of June 19, 2000, libstdc++ attempts to use tricky and
65 space-saving features of the GNU toolchain, enabled with
66 <TT>-ffunction-sections -fdata-sections -Wl,--gc-sections</TT>.
67 To obtain maximum benefit from this, binutils after this date
68 should also be used (bugs were fixed with C++ exception handling
69 related to this change in libstdc++-v3). The version of these
70 tools should be <TT>2.10.90</TT>, and you can get snapshots (as
71 well as releases) of binutils
72 <A HREF="ftp://sources.redhat.com/pub/binutils">here</A>.
75 <P>Finally, a few system-specific requirements:
78 <DD>If you are using Cygwin to compile libstdc++-v3 on Win32, you'll
79 have to get a version of the cygwin1.dll that is dated on or
80 after February 1, 2000. This is necessary to successfully run
81 the script "mknumeric_limits" which probes the
83 environment of the host in question -- before this date, Cygwin
84 would freeze when running this script. In addition, you may
85 want to get a current version of libtool (say libtool-1.3.4
86 and above) as earlier versions supposedly had problems creating
90 <DD>We recommend installing the <TT>SUNWxcu4</TT> package from the
91 Solaris CD before configuring the library. You can check for
92 this package as a non-privileged user with the command
93 "pkginfo SUNWxcu4".
99 <H2><A NAME="srcsetup">Setting up the source directories</A></H2>
100 <P><EM>As the libstdc++-v3 sources and the core GCC sources have
101 converged, more and more effort goes to building the
102 library as the default version to be shipped with g++. With the
103 2.90.8 snapshot, and especially for CVS versions after this
104 release, this is treated as the usual scenario. If you want to
105 build the library all by itself, you will need to explicitly
106 disable certain features (like namespaces) since the core GCC
107 library, libgcc.a, will not be rebuilt with those same features.
111 <P>By default, all configurations of libstdc++-v3 now have namespaces
112 enabled. Being able to select/de-select this option was a complex task
113 that had hopelessly confused many otherwise intelligent people, and
114 provided an endless stream of silent cursing and cries for help.
115 Because of this, gcc sources are required, and are no longer optional.
118 <P>The following definitions will be used throughout the rest of this
121 <LI><EM>gccsrcdir</EM>: The directory holding the source of the
122 compiler. It should have several subdirectories like
123 <EM>gccsrcdir</EM>/libio and <EM>gccsrcdir</EM>/gcc.
124 <LI><EM>libsrcdir</EM>: The directory holding the source of the
126 <LI><EM>gccbuilddir</EM>: The build directory for the compiler
127 in <EM>gccsrcdir</EM>. GCC requires that it be built in
128 a different directory than its sources.
129 <LI><EM>libbuilddir</EM>: The build directory for libstdc++.
130 <LI><EM>destdir</EM>: The eventual installation directory for
131 the compiler/libraries, set with the --prefix option to
132 the configure script.
136 <LI>The .8 snapshot and following are intended to replace the
137 library that comes with the compiler, so <EM>libsrcdir</EM>
138 and <EM>libbuilddir</EM> must be contained under
139 <EM>gccsrcdir</EM> and <EM>gccbuilddir</EM>, respectively.
140 <LI>The source, build, and installation directories should
141 not be parents of one another; i.e., these should all be
142 separate directories. Please don't build out of the
147 <P>Since the release of libstdc++-2.90.8, configuration patches have gone
148 into CVS gcc that make the management of the various libstdc++ source
149 trees a bit easier. Because of this, both libstdc++-v2 and
150 libstdc++-v3 and live together more or less in peace, without the need
151 for soft linking. If a CVS gcc source directory after April 5, 2000 is
152 being used, then the directions are slightly different: please pick
153 which of the following two scenarios best represents your particular
157 <P><B>...with gcc-2.95.2</B>
158 <P>Unpack the <EM>gccsrcdir</EM> and go into that directory. For
159 instance, <TT>gcc-2.95.2</TT> is a valid <EM>gccsrcdir</EM>.
160 Once in <EM>gccsrcdir</EM>, you'll need to rename the directories
161 called <TT> libstdc++ </TT> and <TT> libio </TT> like so:
163 mv libstdc++ libstdc++-v2
164 mv libio libio-v2</PRE>
166 <P>Next, unpack the libstdc++-v3 library tarball into the
167 <EM>gccsrcdir</EM> directory; it will create a
168 <EM>libsrcdir</EM> called <TT>libstdc++-<EM>version</EM></TT>:
170 gzip -dc libstdc++-version.tar.gz | tar xf -</PRE>
172 <P>Finally, make a soft link between <EM>libsrcdir</EM> and
173 <TT>libstdc++</TT> so that libstdc++-v3 will be the default C++
176 ln -s <EM>libsrcdir</EM> libstdc++</PRE>
177 This complexity of having two completely separate libstdc++
178 libraries is necessary so that you can unlink <EM>libsrcdir</EM>
179 and update the compiler sources. If you're not this adventurous, or
180 would not like to switch between different C++ standard libraries,
181 this extra effort is probably wasted; just remove the v2 sources.
185 <P><B>...with CVS gcc</B>
186 <P>Check out or download the gcc sources: the resulting source
187 directory is <EM>gccsrcdir</EM>.
189 <P>Next, unpack the libstdc++-v3 library tarball into this
190 <EM>gccsrcdir</EM> directory; it will create a
191 <EM>libsrcdir</EM> called <TT>libstdc++-<EM>version</EM></TT>:
193 gzip -dc libstdc++-version.tar.gz | tar xf -</PRE>
196 <P>If CVS libstdc++-v3 is being used instead of a snapshot's tarball,
197 then move the source directory from the CVS checkout into the
198 <EM>gccsrcdir</EM> directory.
200 <P>Finally, rename <EM>libsrcdir</EM> to <TT>libstdc++-v3</TT> so that
201 gcc's configure flags will be able to deal with the new library.
203 mv <EM>libsrcdir</EM> libstdc++-v3</PRE>
209 <H2><A NAME="config">Configuring</A></H2>
210 <P>Due to namespaces, when building libstdc++-v3 you'll have to configure
211 the entire <EM>gccsrcdir</EM> directory. The full list of libstdc++-v3
212 specific configuration options, not dependent on the specific compiler
213 release being used, can be found <A HREF="configopts.html">here</A>.
215 <P>Consider possibly using --enable-languages=c++ to save time by only
216 building the C++ language parts.
219 <P><B>...with gcc-2.95.2</B>
221 <EM>gccsrcdir</EM>/configure --prefix=<EM>destdir</EM></PRE>
224 <P><B>...with CVS gcc</B>
226 <EM>gccsrcdir</EM>/configure --prefix=<EM>destdir</EM> --enable-libstdcxx-v3</PRE>
229 <P>Adding <TT>--enable-libstdcxx-v3</TT> automatically selects libstdc++-v3
230 as the C++ library to be used alongside the C++ compiler being built,
231 and also enables -fhonor-std by default. This option is not available
237 <H2><A NAME="install">Building and installing the library</A></H2>
238 <P>Now you have a few options:</P>
239 <H3>[re]building <EM>everything</EM></H3>
240 <P>If you're building GCC from scratch, you can do the usual
241 <TT> 'make bootstrap' </TT> here, and libstdc++-v3 will be built
242 as its default C++ library. The generated g++ will magically
243 use the correct headers, link against the correct library
244 binary, and in general using libstdc++-v3 will be a piece of
245 cake. You're done; run <TT>'make install'</TT> (the GCC
246 Installation instructions) to put the new compiler and libraries
250 <H3>[re]building only libstdc++</H3>
251 <P>Due to differences in the configure process, the resulting Makefiles
252 in the<EM>gccbuilddir</EM> will have different rules depending on
253 the source base being used.
256 <P><B>...with gcc-2.95.2</B>
258 <EM>libstdc++-rule</EM> is <TT>libstdc++</TT>
262 <P><B>...with CVS gcc</B>
264 <EM>libstdc++-rule</EM> is <TT>libstdc++-v3</TT>
268 <P>To rebuild just libstdc++, use:
270 make all-target-<EM>libstdc++-rule</EM></PRE>
271 This will configure and build the C++ library in the
272 <EM>gccbuilddir/cpu-vendor-OS/</EM>libstdc++ directory.
273 As en example, for CVS gcc this would be
274 <TT>make all-target-libstdc++-v3</TT>, and for gcc-2.95.2 it would be
275 <TT>make all-target-libstdc++</TT>
277 <P>If the build fails with a "warning: can't inline call"
278 message when compiling stringMAIN.cc, see <A HREF="#Werror">the
279 resolution at the end of this document</A>.
281 <P>If you are rebuilding from a previous build [attempt], some
282 information is kept in a cache file. This is stored in
283 <EM>gccbuilddir/cpu-vendor-OS/</EM> if you are building with
284 multilibs (the default), or in
285 <EM>gccbuilddir/cpu-vendor-OS/</EM>libstdc++-v3 if you have
286 multilibs disabled. The filename is config.cache; if previous
287 information is causing problems, you can delete it entirely, or
288 simply edit it and remove lines.
290 <P>You're done. Now install the rebuilt pieces with
296 make install-target-<EM>libstdc++-rule</EM></PRE>
301 <H2><A NAME="postinstall">Post-installation</A></H2>
302 <P>Installation will create the <EM>destdir</EM> directory and
303 populate it with subdirectories:
311 <P>You can check the status of the build without installing it using
314 or you can check the status of the installed library using
316 make check-target-<EM>libstdc++-rule</EM></PRE>
317 These commands will create a 'testsuite' directory underneath
318 <EM>libbuilddir</EM> containing the results of the tests. We are
319 interested in any strange failures of the testsuite; please see
320 <A HREF="faq/index.html#2_4">FAQ 2.4</A> for which files to examine.
325 <H2><A NAME="usage">Using the library</A></H2>
326 <LI><B>Find the new library at runtime (shared linking only)</B>
327 <P>If you only built a static library (libstdc++.a), or if you
328 specified static linking, you don't have to worry about this.
329 But if you built a shared library (libstdc++.so) and linked
330 against it, then you will need to find that library when you
333 <P>Methods vary for different platforms and different styles, but
334 the usual ones are printed to the screen during installation.
337 <LI>At runtime set LD_LIBRARY_PATH in your environment correctly,
338 so that the shared library for libstdc++ can be found and
339 loaded. Be certain that you understand all of the other
340 implications and behavior of LD_LIBRARY_PATH first (few
341 people do, and they get into trouble).
342 <LI>Compile the path to find the library at runtime into the
343 program. This can be done by passing certain options to g++,
344 which will in turn pass them on to the linker. The exact
345 format of the options is dependent on which linker you use:
347 <LI>GNU ld (default on Linux):<TT> -Wl,--rpath -Wl,<EM>destdir</EM>/lib</TT>
348 <LI>IRIX ld:<TT> -Wl,-rpath -Wl,<EM>destdir</EM>/lib</TT>
349 <LI>Solaris ld:<TT> -Wl,-R<EM>destdir</EM>/lib</TT>
354 <P>Use the <TT>ldd(1)</TT> utility to show which library the system
355 thinks it will get at runtime.
362 <H3><A NAME="Werror"><TT>warning: can't inline call to</TT>...</A></H3>
363 <P>When building the .8 snapshot with g++ 2.95.2, compilation may halt
364 with this warning message. The "problem" is the -Werror
365 flag being passed to the compiler, which says to treat warnings as
366 errors. (This plus a high warning level makes us track down bugs
367 <EM>quickly</EM>.) The compiler can't inline a certain call, prints
370 <P>The workaround is to edit either <EM>libsrcdir</EM>/src/Makefile.in
371 (before configuring) or <EM>bld-libstdc++</EM>/src/Makefile
372 (after configuring). There's one line that reads
374 WERROR = -Werror</PRE>
375 Delete the flag itself, so that the line reads
378 Then the compiler will still print a warning, but it won't die.
380 <P>For the curious, this "problem" is actually a symptom
381 of something else. The compiler in CVS could inline more than what
382 2.95.2 does, and the libstdc++ changes were made with that
383 compiler. One of the libstdc++ maintainers explains this
384 <A HREF="http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00420.html">here</A>.
386 <P>This has been patched in current CVS sources.
392 <H2><A NAME=""></A></H2>
398 <!-- ####################################################### -->
401 <P CLASS="fineprint"><EM>
402 Comments and suggestions are welcome, and may be sent to
403 <A HREF="mailto:pme@sources.redhat.com">Phil Edwards</A> or
404 <A HREF="mailto:gdr@gcc.gnu.org">Gabriel Dos Reis</A>.
405 <BR> $Id: install.html,v 1.12 2000/12/03 23:47:47 jsm28 Exp $