Keywords: ISO C++ , library

Chapter 3. Using
Prev | Part I. Introduction | Next

## Chapter 3. Using

## Linking Library Binary Files

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,-R`destdir`/lib`

  - More...? Let us know!

Use the ldd 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.

Prev | Up | Next
Test | Home | Headers