13

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!

0

5 Answers 5

24

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.

2
  • 2
    sudo apt install --reinstall build-essential fixed the error for me, thanks! May 20, 2019 at 17:56
  • I added "-get" after "apt" to be "sudo apt-get install --reinstall build-essential", so that the computer executes the command successfully. Thank you. Peace. Jul 12, 2020 at 1:42
7

Run:

sudo apt install --reinstall gcc-5.4

This reinstalls gcc. Reinstalling sometimes fixes problems.

0
1

Install missing library:

sudo apt install libc6-dev
0

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

1
  • 3
    sorry, how to change C/C++ Configurations?
    – Jing He
    Sep 18, 2021 at 15:42
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.

1
  • 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? Mar 23 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.