title: Use RPATH to point to libc library
body: <p>I need to deploy my shared library (.so) in an ancient linux distro (CentOS 6.5).</p>
  
  <p>The problem is that I'm actually compiling my code using CentOS 7 (gcc 4.8.2) and the libc versions are different.</p>
  
  <p>My code depends on the GLIBC 2.14, however, the newest GLIBC version at CentOS 6.5 is 2.13.</p>
  
  <p>I would like to use the <em>RPATH</em> mechanism and deploy the libc files along with the shared library file (.so).</p>
  
  <p>Is this even possible?</p>
  
  <h1>What I did so far</h1>
  
  <p>I've created a directory containing:</p>
  
  <p><code>$ ls
  ld-linux-x86-64.so.2  libc.so.6  libgcc_s.so.1  libm.so.6  libstdc++.so.6
  </code></p>
  
  <h2>-static-libgcc and -static-libstdc++</h2>
  
  <p>These help with the problem of GLIBCXX.
  However, the GLIBC version problem remains:</p>
  
  <p><code>/lib64/libc.so.6: version `GLIBC_2.14' not found (required by sss_reactions/libsss_reactions.so)</code></p>
  
  <h2>--rpath and --dynamic-linker</h2>
  
  <p>Using the <code>readelf</code> utility I saw that the RPATH was correctly set, and calling <code>ldd</code> on the library also points to the correct directory (containing the newer libc).</p>
  
  <p>However, when I try to load the library with <code>dlopen()</code> I get the same error:</p>
  
  <p><code>/lib64/libc.so.6: version `GLIBC_2.14' not found (required by sss_reactions/libsss_reactions.so)</code></p>
  
  <h2>Setting LD_LIBRARY_PATH</h2>
  
  <p>In this case, I get this error:</p>
  
  <p><code>$ LD_LIBRARY_PATH=../dist/ ./Dlopen
  ./Dlopen: relocation error: ../dist/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
  </code></p>