Page 1 of 1

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

Posted: Wed Jan 30, 2013 4:39 pm
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.

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

Posted: Wed Jan 30, 2013 6:11 pm
by bjornmu
What were you trying to do, and how does Hello.c look like?

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

Posted: Wed Jan 30, 2013 6:39 pm
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.

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

Posted: Thu Jan 31, 2013 8:48 am
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.

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

Posted: Thu Jan 31, 2013 12:38 pm
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.

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

Posted: Thu Sep 11, 2014 5:37 pm
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?

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

Posted: Tue Sep 23, 2014 8:25 am
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?

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

Posted: Tue Sep 30, 2014 5:10 pm
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....