title: How to build a C program using a custom version of glibc and static linking?
body: <p>I have built glibc 2.14 and installed it in directory <code>~/GLIBC/glibc_install</code>. Now I want to build and run programs using this C library instead of my system's default C library. </p>
  
  <ul>
  <li><p>To be sure that I was using my custom glibc, I added a call to puts into <code>glibc/stdio-common/printf.c:__printf</code> to print a message.</p></li>
  <li><p>Then I rebuilt and reinstalled glibc.</p></li>
  <li><p>Then I wrote a "Hello, World" program and tried to compile and link it as follows:</p>
  
  <pre><code>gcc -nodefaultlibs -static -lgcc -L~/GLIBC/glibc_install/lib -o myprog myprog.c
  </code></pre></li>
  </ul>
  
  <p>But I get the following linker error report:</p>
  
  <pre><code>/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
  (.text+0x19): undefined reference to `__libc_csu_init'
  /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
  (.text+0x25): undefined reference to `__libc_start_main'
  /tmp/ccACTQEp.o: In function `main':
  c1.c:(.text+0xa): undefined reference to `puts'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>What am I doing wrong?</p>