Compiling Library Errors
I compiled my program successfully but when I try to run the executable I get a library error similar to: ld.so.1: a.out: fatal: libstdc++.so.2.10.0: open failed: No such file or directory.
GCC no longer specifies a runpath so that the dynamic linker can find dynamic libraries at runtime. Please see the GCC FAQ for more information about this. You will need to do one of the following. Please note, these examples refer to the case where your program needs a library found in /usr/local/lib, if the library is in some other location you must adjust accordingly.
- Set your LD_LIBRARY_PATH environment variable either at the command line or permanently in your .cshrc with the following (for csh users): setenv LD_LIBRARY_PATH /usr/local/lib
- Write a small wrapper script that first sets the LD_LIBRARY_PATH environment variable then executes the program. This is especially useful if you need to set other environment variables too.
- Read the "Linker Options" section of the gcc man page along with the ld man page for information on adding a directory to the runtine library search path with something like "-Wl,-R /usr/local/lib".