The latest version of this document is always available at http://gcc.gnu.org/onlinedocs/libstdc++/install.html.
To the libstdc++-v3 homepage.
You will need a recent version of g++ to compile the snapshot of libstdc++, one of the post-2.95.2 GCC snapshots (insert standard caveat about using snapshots rather than formal releases). You will need the full source distribution to whatever compiler release you are using. The GCC snapshots can be had from one of the sites on their mirror list.
In addition, if you plan to modify the makefiles or regenerate the configure scripts you'll need the nuevo automake, libtool and autoconf to regenerate the Makefiles and configure scripts. These tools are all required to be installed in the same location (most linux distributions install these tools by default, so no worries.)
If you don't have bash, and want to run 'make check' to test your build, you'll need to get bash 2.x. Also recommended is GNU Make, since it is the only 'make' that will parse these makefiles correctly.
As of June 19, 2000, libstdc++ attempts to use tricky and space-saving features of the GNU toolchain, enabled with -ffunction-sections -fdata-sections -Wl,--gc-sections. To obtain maximum benefit from this, binutils after this date should also be used (bugs were fixed with C++ exception handling related to this change in libstdc++-v3). The version of these tools should be 2.10.90, and you can get snapshots (as well as releases) of binutils here.
Finally, a few system-specific requirements:
As the libstdc++-v3 sources and the core GCC sources have converged, more and more effort goes to building the library as the default version to be shipped with g++. With the 2.90.8 snapshot, and especially for CVS versions after this release, this is treated as the usual scenario. If you want to build the library all by itself, you will need to explicitly disable certain features (like namespaces) since the core GCC library, libgcc.a, will not be rebuilt with those same features.
By default, all configurations of libstdc++-v3 now have namespaces enabled. Being able to select/de-select this option was a complex task that had hopelessly confused many otherwise intelligent people, and provided an endless stream of silent cursing and cries for help. Because of this, gcc sources are required, and are no longer optional.
The following definitions will be used throughout the rest of this document:
Since the release of libstdc++-2.90.8, configuration patches have gone into CVS gcc that make the management of the various libstdc++ source trees a bit easier. Because of this, both libstdc++-v2 and libstdc++-v3 and live together in peace, without the need for soft linking. The setup instructions are slightly different, depending on whether you want to use CVS gcc or a snapshot. Please choose the appropriate scenario:
...with a gcc-2.9[67] snapshot
Unpack the gccsrcdir and go into that directory. For X instance, gcc-2.95.2 is a valid gccsrcdir. Once in gccsrcdir, you'll need to rename the libstdc++-v3 directory which comes with that snapshot:
mv libstdc++-v3 libstdc++-v3-previous
Next, unpack the libstdc++-v3 library tarball into the gccsrcdir directory; it will create a libsrcdir called libstdc++-version:
gzip -dc libstdc++-version.tar.gz | tar xf -
Finally, make a soft link between libsrcdir and libstdc++-v3 so that libstdc++-v3 will be the default C++ library used.
ln -s libsrcdir libstdc++-v3
...with CVS gcc
Check out or download the gcc sources: the resulting source directory is gccsrcdir. Once in gccsrcdir, you'll need to rename the libstdc++-v3 directory which comes with that snapshot: mv libstdc++-v3 libstdc++-v3-previous
Next, unpack the libstdc++-v3 library tarball into this gccsrcdir directory; it will create a libsrcdir called libstdc++-version:
gzip -dc libstdc++-version.tar.gz | tar xf -
Finally, rename libsrcdir to libstdc++-v3 so that gcc's configure flags will be able to deal with the new library.
mv libsrcdir libstdc++-v3
If you have never done this before, you should read the basic GCC Installation Instructions first.
Due to namespaces, when building libstdc++-v3 you'll have to configure the entire gccsrcdir directory. The full list of libstdc++-v3 specific configuration options, not dependent on the specific compiler release being used, can be found here.
Consider possibly using --enable-languages=c++ to save time by only building the C++ language parts.
cd gccbuilddir gccsrcdir/configure --prefix=destdir --enable-libstdcxx-v3
Adding --enable-libstdcxx-v3 automatically selects libstdc++-v3 as the C++ library to be used alongside the C++ compiler being built, and also enables -fhonor-std by default. This option is not available with gcc-2.95.2.
Now you have a few options:
If you're building GCC from scratch, you can do the usual 'make bootstrap' here, and libstdc++-v3 will be built as its default C++ library. The generated g++ will magically use the correct headers, link against the correct library binary, and in general using libstdc++-v3 will be a piece of cake. You're done; run 'make install' (see the GCC installation instructions) to put the new compiler and libraries into place.
To rebuild just libstdc++, use:
make all-target-libstdc++-v3This will configure and build the C++ library in the gccbuilddir/cpu-vendor-OS/libstdc++ directory.
If the build fails with a "warning: can't inline call" message when compiling stringMAIN.cc, see the resolution at the end of this document.
If you are rebuilding from a previous build [attempt], some information is kept in a cache file. This is stored in gccbuilddir/cpu-vendor-OS/ if you are building with multilibs (the default), or in gccbuilddir/cpu-vendor-OS/libstdc++-v3 if you have multilibs disabled. The filename is config.cache; if previous information is causing problems, you can delete it entirely, or simply edit it and remove lines.
You're done. Now install the rebuilt pieces with
make installor
make install-gcc make install-target-libstdc++-rule
Installation will create the destdir directory and populate it with subdirectories:
lib/ include/g++-v3/ bits/ ext/ cpu-vendor-OS/include/g++-v3/ bits/ ext/
You can check the status of the build without installing it using
make checkor you can check the status of the installed library using
make check-installin the libbuilddir directory. These commands will create a 'testsuite' directory underneath libbuilddir containing the results of the tests. We are interested in any strange failures of the testsuite; please see FAQ 2.4 for which files to examine.
If you only built a static library (libstdc++.a), or if you specified static linking, you don't have to worry about this. But if you built a shared library (libstdc++.so) and linked against it, then you will need to find that library when you run the executable.
Methods vary for different platforms and different styles, but the usual ones are printed to the screen during installation. They include:
Use the ldd(1) utility to show which library the system thinks it will get at runtime.
When building the .8 snapshot with g++ 2.95.2, compilation may halt with this warning message. The "problem" is the -Werror flag being passed to the compiler, which says to treat warnings as errors. (This plus a high warning level makes us track down bugs quickly.) The compiler can't inline a certain call, prints a warning, and dies.
The workaround is to edit either libsrcdir/src/Makefile.in (before configuring) or bld-libstdc++/src/Makefile (after configuring). There's one line that reads
WERROR = -WerrorDelete the flag itself, so that the line reads
WERROR =Then the compiler will still print a warning, but it won't die.
For the curious, this "problem" is actually a symptom of something else. The compiler in CVS could inline more than what 2.95.2 does, and the libstdc++ changes were made with that compiler. One of the libstdc++ maintainers explains this here.
This has been patched in current CVS sources.
Comments and suggestions are welcome, and may be sent to
Phil Edwards or
Gabriel Dos Reis.
$Id: install.html,v 1.1 2000/12/10 04:03:08 pme Exp $