On Sun, Jun 25, 2006 at 07:47:52PM -0400, Paul Hilfinger wrote:
> 
> I have a situation (on Linux or Solaris, at least), in which I
> install versions of GCC in non-standard directories (specifically,
> directories not owned & operated by root).  With such an
> installation, when a GCC link finds a definition of an external
> reference in a shared library that is part of the .../lib
> subdirectory used by this installation, it treats the shared library
> as if it were also installed in one of the standard locations known
> to the dynamic linker, and does NOT store the path to the directory
> in which that library is found.  The result is that to run the
> linked executable, one must either 

So you simply want the RPATH entry in the executable created by "gcc
-o foo foo.c" to contain an entry to locate libgcc.so and
libstdc++.so?

You can modify the specs file to _automatically_ add the -R/-Wl,-rpath
when linking. Below is a possible patch for the GCC 4.0.2 specs file
to accomplish it for Solaris. Linux is handled in a similar way.

-- 
albert chin ([EMAIL PROTECTED])

-- snip snip
--- specs.orig  Sun Jun 25 23:30:01 2006
+++ specs       Fri Oct 21 00:05:58 2005
@@ -173,6 +173,12 @@
 *link_arch:
 %{m32:%(link_arch32)} %{m64:%(link_arch64)} 
%{!m32:%{!m64:%(link_arch_default)}} 
 
+*rpath:
+-R[gcc library path]
+
+*rpath64:
+-R[gcc library path]/sparcv9
+
 *link_command:
-%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:    %(linker) %l %{pie:} %X %{o*} 
%{A} %{d} %{e*} %{m} %{N} %{n} %{r}    %{s} %{t} %{u*} %{x} %{z} %{Z} 
%{!A:%{!nostdlib:%{!nostartfiles:%S}}}    %{static:} %{L*} %(mfwrap) 
%(link_libgcc) %o %(mflib)    %{fprofile-arcs|fprofile-generate:-lgcov}    
%{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}    
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}
+%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:    %(linker) %l %{pie:} %X %{o*} 
%{A} %{d} %{e*} %{m} %{N} %{n} %{r}    %{s} %{t} %{u*} %{x} %{z} %{Z} 
%{!A:%{!nostdlib:%{!nostartfiles:%S}}}    %{static:} %{L*} %(mfwrap) 
%(link_libgcc) %o %(mflib)    %{fprofile-arcs|fprofile-generate:-lgcov}    
%{!nostdlib:%{!nodefaultlibs:%{!m64:%(rpath)} %{m64:%(rpath64)} 
%(link_gcc_c_sequence)}}    %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}
 

Reply via email to