15

gcc worked perfectly fine until I updated to Ubuntu 16.04 and now when I run:

gcc file.c

an error shows up:

file.c:1:18: fatal error: stdio.h: No such file or directory
compilation terminated.

I checked if stdio.h was there and it still was in /usr/include/stdio.h. Please help!

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
Camden
  • 617
  • 2
  • 6
  • 17

6 Answers6

27

First run:

find /usr/include/ -name "stdio.h"

If no files are returned, run:

sudo apt install --reinstall build-essential

That will reinstall any missing files.

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
salafi
  • 595
  • 6
  • 6
7

Run:

sudo apt install --reinstall gcc-5.4

This reinstalls gcc. Reinstalling sometimes fixes problems.

fosslinux
  • 3,771
  • 4
  • 28
  • 46
1

Install missing library:

sudo apt install libc6-dev
TOUDIdel
  • 111
  • 2
0

Going into the C/C++ Configurations and adding /usr/include/** fixed it for me.

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
Ryan C
  • 1
  • 1
0

Go to the View tab if you are using VSCode. Search for C/C++ edit configuration(UI). Copy/paste these paths to the include path section of the configuration.

/usr/include/
/usr/include/x86_64-linux-gnu
/usr/include/linux
/usr/include/c++/9/tr1
/usr/include/c++/9

You have to paste these paths.

Save your .c file and run it as gcc /path in terminal.

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
  • 1
    Hi! Thanks for your answer! Could you also please add a couple of screenshots to make it easier for users to find and apply this setting? – BeastOfCaerbannog Mar 23 '22 at 09:56
0

It was the same error in Xubuntu 22 in MPLAB. i fix it using

sudo apt-get install avr-libc