About Linking of a simple C++ prog.
Peter Kurpis
pkurpis@keck.hawaii.edu
Thu Oct 11 12:13:00 GMT 2001
> I have tried g++ & gcc -lstdc++, it doesn't work either, although
> the error messages is different as follows:
> $PWD$g++ test.cpp
> $PWD$./a.out
> ld.so.1: ./a.out: fatal: libstdc++.so.2.10.0: open failed: No such file or direc
> tory
> Killed
Your program linked correctly this time, as an executable was created, but
your executable can't find libstdc++.so at runtime. There are a couple of
options:
- you can tell the executable where to look e.g. on Solaris, you
would set the environment variable
setenv LD_RUN_PATH <path_to_libstdc++>
- you can recompile, this time hardwiring the runtime search path
into the executable:
g++ -Wl,-rpath <path_to_libstdc++> test.cpp
assuming your g++ was configured to use GNU ld
note that that's an ell, not numeric 'one'
More information about the Gcc-help
mailing list