title: How to build a shared library (.so) without hardcoded full dependency paths?
body: <p>I need to build two 3rd party shared libraries, so their .so files will be reused by other projects. However, after build one of these libraries contains hardcoded path to another. This path is invalid on other machines and causes linker warnings. How can I prevent the full path from being embedded in the resulting .so files?</p>
  
  <p>Details:</p>
  
  <p>First library source: <code>~/dev/A</code><br/>
  Second library source: <code>~/dev/B</code></p>
  
  <p>Both of them have <code>configure</code> script to generate make files. Library <code>B</code> depends on <code>A</code>. So, first I build <code>A</code>:</p>
  
  <pre><code>$ ~/dev/A/configure --prefix=~/dev/A-install
  $ make &amp;&amp; make install
  </code></pre>
  
  <p>Then I build <code>B</code>:</p>
  
  <pre><code>$ ~/dev/B/configure --prefix=~/dev/B-install --with-A=~/dev/A-install
  $ make &amp;&amp; make install
  </code></pre>
  
  <p>Then I want to upload the contents of <code>~/dev/A-install</code> and <code>~/dev/B-install</code> to our file server, so other teams and build machines can use the binaries. But they get linker warnings when they try to use <code>B</code>:</p>
  
  <pre><code>/usr/bin/ld: warning: libA.so.2, needed by /.../deps/B/lib/libB.so, not found (try using -rpath or -rpath-link)
  </code></pre>
  
  <p>When I run <code>ldd libB.so</code> it gives:</p>
  
  <pre><code>...
  libA.so.2 =&gt; /home/alex/dev/A-install/lib/libA.so.2
  </code></pre>
  
  <p>Obviously this path exists only on my machine and cannot be found on other machines.</p>
  
  <p>How can I remove full hardcoded path from <code>libB.so</code>?</p>
  
  <p>Thanks.</p>