title: How to detect libc name and version in cross-compiler environments?
body: <p>I have a few cross-compilers on my linux desktop. Some use glibc and some use uclibc (and in future there could be other <code>libc</code>s too).</p>
  
  <p>Currently, I can go into their sysroot directories and search for <code>libc.so</code> and try to find which file name it points to (for eg. <code>libc.so</code> -> <code>libuClibc-1.0.12.so</code>) and I fetch their names. But this won't last long if naming changes or if cross-compiler itself changes.</p>
  
  <p>Is there a better/reliable programmatic way of detecting the name and version of the <code>libc</code> being used by a target cross compiler? Or are there any introspection tools available to get details about the target ceros</p>
  
  <p>Note: There are a few similar questions here which normally point to <code>#include &lt;features.h&gt;</code> file or similar. That works fine if the generated code can also run on the host. But not suitable for cross-compile environments.</p>
  
  <p>So has anyone been able to detect much more reliably?</p>
  
  <p>EDIT: On the off chance someone comes here looking for detecting musl libc specifically, I've <a href="https://stackoverflow.com/questions/58177815/how-to-actually-detect-musl-libc/60471114#60471114">answered another question</a> on SO that is related to this question.</p>