gcc can not find stdio.h 'no such file'

Asked by Cliffm on 2012-12-08

Hello my name is Cliff
The GCC has always worked before upgrading to Ubuntu 12.10.

now it tells me stdio.h no such file.
The test file is std hello.c file

#include < stdio.h >

void main()
{
    printf("\nHello World\n");
}

!gcc hello.c
hello.c:1:21: fatal error: stdio.h : No such file or directory
compilation terminated.

shell returned 1

installed build-essential

cliffm@cjm:~$ sudo apt-get install build-essential
[sudo] password for cliffm:
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version.
build-essential set to manually installed.

Still will not compile?

Thanks for any help

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
marcobra (Marco Braida)
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#1

try to install

libc6-dev

Revision history for this message
Cliffm (c2mcatee) said :
#2

Hi Marco

This is the result.

sudo apt-get install libc6-dev
[sudo] password for cliffm:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libc6-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#3

#include "stdio.h"

void main()
{
    printf("\nHello World\n");
}

Try this...

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#4

compile with

gcc -o hello -ansi hello.c

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#5

Run with

./hello

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#6

remove spaces in <stdio.h> : try this code...

#include <stdio.h>

void main()
{
    printf("\nHello World\n");
}

Save to hello.c, then compile and run with this row:

gcc -o hello -ansi hello.c; ./hello

Revision history for this message
Cliffm (c2mcatee) said :
#7

#include "stdio.h"

void main()
{
    printf("\nHello World\n");
}

:!gcc -o hello -ansi hello.c
hello.c:1:21: fatal error: stdio.h : No such file or directory
compilation terminated.

shell returned 1

:!./hello
/bin/bash: ./hello: No such file or directory

shell returned 127

Revision history for this message
Cliffm (c2mcatee) said :
#8

Marco
This worked
What is different in Ubuntu12.10 than there was in 12.04 and earlier?
So adding the -ansi seems to be the answer.
Are there any other changes I should make?

Thanks for the help
Cliff

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#9

This is c/ompilingworking without -ansi flag:

#include <stdio.h>

void main()
{
    printf("\nHello World\n");
}

Save to hello.c, then compile and run with this row:

gcc -o hello hello.c; ./hello

Revision history for this message
Cliffm (c2mcatee) said :
#10

Marco
run without ansi flag

#include <stdio>

void main()
{
    printf("\nHello World\n")
}

:!gcc -o hello hello.c
hello.c:1:18: fatal error: stdio: No such file or directory
compilation terminated.

shell returned 1

Revision history for this message
Best marcobra (Marco Braida) (marcobra) said :
#11

Please note:

#include <stdio.h>

not

#include <stdio>

Revision history for this message
Cliffm (c2mcatee) said :
#12

Also included ';'

#include <stdio.h>

void main()
{
    printf("\nHello World\n");
}

!gcc -o hello hello.c

:!./hello

Hello World

shell returned 13

That worked
Thanks Marco
I was following a C tutorial book and it recommended 'gcc hello.c' only.
Thanks again

Revision history for this message
lohi (lohiram) said :
#26

I'm trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I'm getting the following error at compile time:

gcc: fatal error: stdio.h: No such file or directory
I then tried a simple Hello World program:

#include <stdio.h>

int main(int argc, const char *argv[])
{
    printf("Hello, world!");
    return 0;
}
Again, upon running gcc -o ~/hello ~/hello.c, I got the same error. I'm using an experimental version of gcc, but it seems implausible that there would be a release which generated errors upon importing stdio. What could be causing this issue, and how can it be fixed?
https://myboyapk.fun/

Revision history for this message
ranuka johs (udantaroy) said :
#27

As a debugger, GDB is a veritable Swiss Army knife. And just like exploring all of the non-obvious uses of a those knives, your initial response to the scope of GDB’s feature set is likely to be one of bewilderment, subsequent confusion, and occasional laughter. This is an understandable reaction in the case of the Swiss Army knife as one is unlikely to be in the midst of an army campaign or trapped in the wilderness. Similarly, it takes a tricky debugging session to really learn to appreciate GDB’s feature set. http://logindb.online/gmail-pc-217908