I am trying to compile a program using make on Mac OS X with gcc4.2. But I'm getting this error:
fpu_control.h: No such file or directory

I have never had a problem with an include file before and I'm rather confused! I have googled fpu_control.h, but I can't find anywhere to download it.

If anyone can help, I would be very grateful!

Dani AI

Generated

fpu_control.h is a glibc/Linux header that manipulates the x87 FPU control word (precision, rounding, exception masks). Apple OS X does not ship glibc, so the system toolchain on a Mac will not provide that header — which is why the compile stops with "No such file or directory" (as reported). 's suggestion to check include paths is valid, but simply copying a Linux header into the system includes is brittle unless the rest of the implementation is compatible.

There are three practical approaches that work for Mac builds:

  • Prefer the portable C99 <fenv.h> API when the code only needs to change rounding or save/restore the FP environment. Example pattern:
#include <fenv.h>

/* save current rounding mode */
int old = fegetround();

/* set rounding to nearest */
if (fesetround(FE_TONEAREST) != 0) { /* handle error */ }

/* floating-point work here */

/* restore rounding mode */
fesetround(old);

Use #pragma STDC FENV_ACCESS ON and, if relying on strict rounding semantics, compile with the appropriate flags (for GCC: -frounding-math) so the optimizer does not assume a fixed rounding mode.

  • If the program requires x87 precision control (extended vs double) or uses glibc-specific control-word tricks, consider a compatibility shim. The thread pointers from and to a small "fpmath"/fpu_control compatibility header are useful short-term fixes; verify the header’s license and test thoroughly on the target architectures.

  • If porting is impractical, build on a Linux environment (VM or container) where fpu_control.h is provided.

A useful first step is to search the source for fpu_control, fpu_control_t and _FPU_ macros to see whether the code only manipulates rounding (map to <fenv.h>) or needs low-level x87 precision (requires a shim or Linux build).

Recommended Answers

All 6 Replies

Make sure the header is in your include directory of the compiler/IDE. If you don't have the file, don't use it.

Thanks SgtMe. Unfortunately, I need fpu_control.h. The program I am trying to compile that needs it was not written by me. It has to do with floating point precision.

I thought fpu_control.h would be a standard sort of file. But the only information I can find out about it is that it isn't included in my compiler (gcc 4.2). I just can't find out anything else about it! Thanks for your help.

This could be helpful.

Thank you very, very much nezachem and tawes01. These do indeed look very helpful! I googled for hours and couldn't find a thing!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.