10-22-04 12:49 PM
On Thu, 21 Oct 2004 12:42:36 -0700, Doctor Bones wrote:
> PLease help. I have a decent amount of C++ experience on Windows, but
> know nothing about Unix. I wrote a simple "Hello World" program on a
> Solaris box which includes <iostream>. The program compiles when I
> run g++ but when I attempt to execute a.out I get the following error:
>
> ld.so.1: ./a.out: fatal: libstdc++.so.5: open failed: No such file or
> directory
g++ keeps its iostream implementation in the library libstdc++.so.
A .so (shared object) file is like a dll file.
The problem is that g++, or more correctly its libstdc++.so library
is not installed into any of the default system library directories
and the program loader cannot find it. This is the error message
you are seing. The command "ldd a.out" also tells you that it cannot
find the path for the library.
You have three options.
1. You can get your system administrator to install g++ and its
header files and libraries on the system.
2. You can set the LD_LIBRARY_PATH environment variable to include
the path to where your libstdc++.so library is currently located.
Chances are that it is located in the same directory as libgcc,
which can be found with "g++ -print-libgcc-file-name".
3. Instead of linking with the shared version (the dll) of the
library, you can link with the static version. This means that
all the necessary library code is put directly into your program.
So the program will grow in size, but it will not have external
dependencies. This is done by adding the "-static" compiler option
when you compile with g++.
--
mail1dotstofanetdotdk
[ Post a follow-up to this message ]
|