title: lgcc_s not found by ld even if libgcc_s.so link is not broken on Ubuntu 12.10
body: <p>I'm facing a problem compiling with <code>gcc</code> with <code>-static</code>, <code>-static-libgcc</code> flags enabled for compiler and <code>-Wl,-static</code> flag enabled for linker on Ubuntu 12.10. But the application builds fine with dynamic linking (without using those flags).<p>
  <code>/usr/bin/ld: cannot find -lgcc_s</code><p>
  After looking at the suggestions over the internet, I found most of the time it's a problem with broken link from <code>/usr/lib/gcc/i686-linux-gnu/x.x/libgcc_s.so</code> to <code>/lib/libgcc_s.so.1</code>. But in my case <code>/usr/lib/gcc/i686-linux-gnu/4.7/libgcc_s.so</code> is pointing to <code>/lib/i386-linux-gnu/libgcc_s.so.1</code> which does exist.<p></p>
  
  <pre><code>$ ls -l /usr/lib/gcc/i686-linux-gnu/4.7/libgcc_s.so
  lrwxrwxrwx 1 root root 33 Sep 21  2012 /usr/lib/gcc/i686-linux-gnu/4.7/libgcc_s.so -&gt; /lib/i386-linux-gnu/libgcc_s.so.1
  $ ls -l /lib/i386-linux-gnu/libgcc_s.so.1
  -rw-r--r-- 1 root root 116244 Sep 21  2012 /lib/i386-linux-gnu/libgcc_s.so.1
  $ file /lib/i386-linux-gnu/libgcc_s.so.1
  /lib/i386-linux-gnu/libgcc_s.so.1: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x61fa08eda0f264222649f9481f9e0340567d0862, stripped
  </code></pre>
  
  <p>The output of <code>ldconfig</code> shows the following:<p></p>
  
  <pre><code>$ sudo /sbin/ldconfig -v | grep libgcc_s
  /sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory
  /sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory
  /sbin/ldconfig.real: Path `/lib/i386-linux-gnu' given more than once
  /sbin/ldconfig.real: Path `/usr/lib/i386-linux-gnu' given more than once
      libgcc_s.so.1 -&gt; libgcc_s.so.1
  /sbin/ldconfig.real: Cannot stat /usr/lib/i386-linux-gnu/libsoftokn3.so: No such file or directory
  /sbin/ldconfig.real: Cannot stat /usr/lib/i386-linux-gnu/libnss_db.so: No such file or directory
  </code></pre>
  
  <p>Can anyone help me solve this problem with static linking? Also let me know if any further details is needed. Thanks.</p>