/usr/include/x86_64-linux-gnu/sys contains only broken symbolic links

My O/S is Ubuntu 20.04.

The initial problem: I was trying to run a "make" and got errors like:

/usr/include/sys/cdefs.h:453:10: fatal error: bits/long-double.h: No such file or directory
  453 | #include <bits/long-double.h>
      |          ^~~~~~~~~~~~~~~~~~~~

I initially tried solving this by searching for an equivalent header (usually in /usr/include/x86_64-linux-gnu) and adding a symbolic link. The initial ref was typically from /usr/include/c++/9/<whatever>. After a dozen or so of these, there seemed to be a slew of headers missing in /usr/include/sys and each one seemed to have an equivalent in /usr/include/x86_64-linux-gnu/sys. I then tried creating a symlink of the form

/usr/include/sys --> /usr/include/x86_64-linux-gnu/sys

I don't know if that was the cause of my subsequent problems, but it was probably not my brightest idea. It seemed to me that I was going around in circles, because some of the earlier header errors came back. I decided to reinstall the libc6 and libc6:i386. After that all the "headers" in /usr/include/x86_64-linux-gnu/sys were symlinks marked as broken. When I checked the properties of a few, it became clear why... they were all links back to themselves!!

Can anybody give me a hint as to how to undo the damage and get a configuration that will successfully run the Makefile?


You should not touch file structure manually in places where files are controlled by APT. Remove and cancel all such manual interventions. Do not do this next time!

You have to (re)install relevant development package which owns bits/long-double.h file by

sudo apt-get install --reinstall libc6-dev

If you have massive damage then reinstall all the packages which provide includes by using below commands:

sudo apt-get install --reinstall $(dpkg -l | grep ^ii | grep "\-dev" | awk '{print $2}')
sudo apt-get install --reinstall $(dpkg -S /usr/include/ | sed 's/,//g' | sed 's/: \/usr\/include//g')