title: How to replace LD variable in a Makefile to link C objects
body: <p>I'm writing a Makefile for C. I want be able to specify different programs for compilation and linking via environmental variables. However, I want it works without any additional variables too. I was trying to link with ld. However, the default doesn't link with standard C library.</p>
  
  <p>The question:<br>
  <strong>How to link C program with ld or $LD</strong><br>
  Is it possible to get appropriate flags from cc?</p>
  
  <p><strong>I cannot use <code>$(CC)</code> in place of <code>$(LD)</code>. The <code>LD ?= cc</code> doesn't work too.</strong></p>
  
  <p>I want something like this to be true:<br>
  Environment variable CC set to tcc.<br>
  Environment variable LD unset.<br>
  My Makefile compile using tcc and link using system default linker for C.  </p>
  
  <p>Unfortunately, some C compilers are unable to link some libraries. I have this problem with tcc and glfw.</p>
  
  <p>P.S.<br>
  Linux user</p>