title: How to solve undefined reference to functions in fenv.h when using uclibc?
body: <p>I'm trying to test some of the functions in <code>fenv.h</code>, however, when I compile the below function ld fails with <code>undefined reference to 'feclearexcept'</code> and <code>undefined reference to 'fetestexcept'</code>. I'm running hardened gentoo compiled against uclibc, and I suspect that this is at least somewhat related</p>
  
  <pre><code>#include &lt;stdio.h&gt;      /* printf */
  #include &lt;math.h&gt;       /* sqrt */
  #include &lt;fenv.h&gt;      
  #pragma STDC FENV_ACCESS on
  
  int main ()
  {
    feclearexcept (FE_ALL_EXCEPT);
    sqrt(-1);
    if (fetestexcept(FE_INVALID)) printf ("sqrt(-1) raises FE_INVALID\n");
    return 0;
  }
  </code></pre>
  
  <p><code>fenv.h</code> is in <code>/usr/include</code>. There are static and dynamic libraries (<code>libm.a</code>, <code>libm.so</code>) in <code>/usr/lib</code>. I am compiling with <code>gcc -o test test.c -lm</code>; does anyone have any ideas why the linker can't find the relevant functions. It seems like nothing in <code>fenv.h</code> has a corresponding library.</p>
  
  <p>UPDATE: this decade old blog post seems to suggest that fenv is not supported by uclibc. I cannot determine if this is the case still, but if it were is there anything to be done. 
  <a href="http://uclibc.10924.n7.nabble.com/missing-fenv-h-for-qemu-td2703.html" rel="noreferrer">http://uclibc.10924.n7.nabble.com/missing-fenv-h-for-qemu-td2703.html</a></p>