# Getting started: configure, build, install

The latest version of this document is always available at http://gcc.gnu.org/onlinedocs/libstdc++/install.html.

To the libstdc++-v3 homepage.

## Contents

Because libstdc++-v3 is part of GCC, the primary source for installation instructions is the GCC install page. Additional data is given here only where it applies to libstdc++-v3.

- Tools you will need beforehand
- Configuring
- Using the library

## Tools you will need beforehand

The list of software needed to build the library is kept with the rest of the compiler, at http://gcc.gnu.org/install/prerequisites.html. The same page also lists the tools you will need if you wish to modify the source.

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`, or later, and you can get snapshots (as well as releases) of binutils here. The configure process will automatically detect and use these features if the underlying support is present.

Finally, a few system-specific requirements:

linux
  If gcc 3.1.0 or later on is being used on linux, an attempt will be made to use "C" library functionality necessary for C++ named locale support. For gcc 3.2.1 and later, this means that glibc 2.2.5 or later is required and the "C" library de_DE locale information must be installed.

  The configure option --enable-clocale can be used force a particular behavior.

  If the 'gnu' locale model is being used, the following locales are used and tested in the libstdc++ testsuites. The first column is the name of the locale, the second is the character set it is expected to use.

      de_DE               ISO-8859-1
      de_DE@euro          ISO-8859-15
      en_HK               ISO-8859-1
      en_PH               ISO-8859-1
      en_US               ISO-8859-1
      en_US.ISO-8859-1    ISO-8859-1
      en_US.ISO-8859-15   ISO-8859-15
      en_US.UTF-8         UTF-8
      es_ES               ISO-8859-1
      es_MX               ISO-8859-1
      fr_FR               ISO-8859-1
      fr_FR@euro          ISO-8859-15
      is_IS               UTF-8
      it_IT               ISO-8859-1
      ja_JP.eucjp         EUC-JP
      se_NO.UTF-8         UTF-8
      ta_IN               UTF-8
      zh_TW               BIG5

  Failure to have the underlying "C" library locale information installed will mean that C++ named locales for the above regions will not work: because of this, the libstdc++ testsuite will skip the named locale tests. If this isn't an issue, don't worry about it. If named locales are needed, the underlying locale information must be installed. Note that rebuilding libstdc++ after the "C" locales are installed is not necessary.

  To install support for locales, do only one of the following:

  - install all locales
    - with RedHat Linux:

      `export LC_ALL=C`

      `rpm -e glibc-common --nodeps`

      `rpm -i --define "_install_langs all" glibc-common-2.2.5-34.i386.rpm`

    - (instructions for other operating systems solicited)
  - install just the necessary locales
    - with Debian Linux:

      Add the above list, as shown, to the file `/etc/locale.gen`

      run `/usr/sbin/locale-gen`

    - on most Unix-like operating systems:

      `localedef -i de_DE -f ISO-8859-1 de_DE`

      (repeat for each entry in the above list)

    - (instructions for other operating systems solicited)

## Configuring

If you have never done this before, you should read the basic GCC Installation Instructions first. Read all of them. Twice.

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 --other-opts...

## Using the library

### Find the new library at runtime (shared linking only)

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:

- At runtime set LD_LIBRARY_PATH in your environment correctly, so that the shared library for libstdc++ can be found and loaded. Be certain that you understand all of the other implications and behavior of LD_LIBRARY_PATH first (few people do, and they get into trouble).
- Compile the path to find the library at runtime into the program. This can be done by passing certain options to g++, which will in turn pass them on to the linker. The exact format of the options is dependent on which linker you use:
  - GNU ld (default on Linux):`-Wl,--rpath,destdir/lib`
  - IRIX ld:`-Wl,-rpath,destdir/lib`
  - Solaris ld:`-Wl,-Rdestdir/lib`
  - More...? Let us know!

Use the `ldd(1)` utility to show which library the system thinks it will get at runtime.

A libstdc++.la file is also installed, for use with Libtool. If you use Libtool to create your executables, these details are taken care of for you.

See license.html for copying conditions. Comments and suggestions are welcome, and may be sent to the libstdc++ mailing list.