title: How to build a Shared Library but use static glibc on Linux?
body: <p>I'm trying to create a shared library on centos using gcc 4.8.2</p>
  
  <p>shared library code:</p>
  
  <pre><code>//reload.c
  int func(int num){
      return num++;
  }
  </code></pre>
  
  <p>link command:</p>
  
  <pre><code>gcc -fPIC -shared reload.c -o reload.so
  </code></pre>
  
  <p>use ldd command:</p>
  
  <pre><code>linux-vdso.so.1 =&gt;  (0x00007ffe6aa93000)
  libc.so.6 =&gt; /usr/lib64/libc.so.6 (0x00007f27feb97000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f27ff169000)
  </code></pre>
  
  <p>Now, Want to statically link glibc, how to write it? </p>
  
  <p>like it: </p>
  
  <pre><code>ldd xxx.so
      not a dynamic executable
  </code></pre>
  
  <p>I tried the build options, but the error.</p>
  
  <pre><code>gcc -fPIC -shared reload.c -o reload.so -Wl,-Bstatic -lc
  /usr/bin/ld: cannot find -lgcc_s
  /usr/bin/ld: cannot find -lgcc_s
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>thank you very much</p>