gcc fatal error:stdio.h:No such file or directory

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
lmitcham

gcc fatal error:stdio.h:No such file or directory

Post by lmitcham »

Hello.c:1:19: fatal error: stdio.h: No such file or directory

I get this error after installing a fresh Linux Mint 14. I have added the correct directory to path and can see it when I type "echo $PATH" in terminal.

I am new to Linux and any advice is welcome.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: gcc fatal error:stdio.h:No such file or directory

Post by bjornmu »

What were you trying to do, and how does Hello.c look like?
SiKing
Level 5
Level 5
Posts: 571
Joined: Mon Sep 29, 2008 10:57 pm
Location: Las Vegas
Contact:

Re: gcc fatal error:stdio.h:No such file or directory

Post by SiKing »

gcc is a compiler, Hello.c is a source file, stdio.h is a resource file.
The PATH is a variable where binary executables are searched for.
The above two items have absolutely nothign to do with each other!

You were apparently trying to compile something. What are you trying to accomplish, and how are you going about it? We need steps to reproduce to be able to help you.
lmitcham

Re: gcc fatal error:stdio.h:No such file or directory

Post by lmitcham »

I am attempting to get my feet wet with gcc and linux. I was simply creating a simple program, using Kate, from a tutorial. The 'Hello.c' program file is :

Code: Select all

#include <stdio.h>

void main
{
    printf("Hello World\n");
}
I created a directory named "Temp" under >home>mydir>Projects, and stored Hello.c there.

If I open terminal and go to the "Temp" directory and type "gcc Hello.c -o hello1", the response is
"fatal error: stdio.h: No such file or directory"

My first thought was that stdio.h was not in the PATH, so I added it and checked that the PATH was updated by typing
"echo $PATH"

Another attempt to compile produced the same error message.

That is where I am now. I am hopefully missing something simple.
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: gcc fatal error:stdio.h:No such file or directory

Post by bjornmu »

The file should be located under /usr/include and this is the default location so you shouldn't need to tell gcc that. You may first want to double check that you have /usr/include/stdio.h available.

BTW your program won't compile in any case since you've forgotten () after the name of main(). :) But you didn't get that far.
JasonMel

Re: gcc fatal error:stdio.h:No such file or directory

Post by JasonMel »

I have the same problem, and I found my stdio.h in a completely different directory from /usr/include. How do I tell the system where my header files are? And why would my Mint install not know already?
Zetor895

Re: gcc fatal error:stdio.h:No such file or directory

Post by Zetor895 »

JasonMel wrote:I have the same problem, and I found my stdio.h in a completely different directory from /usr/include. How do I tell the system where my header files are? And why would my Mint install not know already?
I am also interested in this. I found stdio.h in /usr/lib/syslinux/com32/include/ directory. Is it OK if i make a symbolic link from here to /usr/include?
Thanks in advance.
EDIT: it seems not. I got an error message during copiling:
~ $ make hello
cc hello.c -o hello
In file included from hello.c:1:0:
/usr/include/stdio.h:8:26: fatal error: klibc/extern.h: No such file or directory
#include <klibc/extern.h>
^
compilation terminated.
make: *** [hello] Error 1

EDIT2:
This solved the issue:

Code: Select all

 sudo apt-get install build-essential
but I am still interested why the symlink did not work?
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: gcc fatal error:stdio.h:No such file or directory

Post by bjornmu »

Probably because that other stdio.h is something completely different from the standard stdio.h and it meant to be used in a different context. No I don't know *what* that is, except it's not the same....
Locked

Return to “Software & Applications”