-   Linux - Software (
-   -   problem in compiling a c program (

kadhir 08-14-2009 01:31 PM

problem in compiling a c program
i have written a simple c program

#include <stdio.h>

int main()
return 0;

$ gcc -o simpleq simpleq.c

the following error occured
simpleq.c:1:19: error: stdio.h: No such file or directory
simpleq.c: In function ‘main’:
simpleq.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

what can be the problem plz suggest some solution

jrtayloriv 08-14-2009 02:03 PM

You should ask questions like this in the Programming forum, not the Linux Software forum.

As far as your problem, though -- are you using Ubuntu? If so, you might need to install the build-essential package, like this:


sudo apt-get install build-essential

David1357 08-14-2009 02:50 PM


Originally Posted by kadhir (Post 3643510)
simpleq.c:1:19: error: stdio.h: No such file or directory

You need to install the standard headers. You should find "stdio.h" in
If it is not there, you do not have the standard headers installed.

Since we do not know what distro you are using, we need more information before we can help you further.

John VV 08-14-2009 03:21 PM

then once the Ubuntu Build-essential are installed change
#include <stdio.h>
-- to --
#include <cstdio>

things are changing in gcc ,<stdio.h> still works but <cstdio> is preferable

David1357 08-17-2009 01:16 PM


Originally Posted by John VV (Post 3643608)
things are changing in gcc, <stdio.h> still works but <cstdio> is preferable

If the code is C, then <stdio.h> should be used. <cstdio> is for C++, and is really a wrapper that eventually includes stdio.h.

scrat75 08-22-2009 10:55 AM

Hi guys!,
I have encountered the same problem as Kadhir.
I have an Ubuntu 9.04 machine on which I installed build-essential package
to be able to compile C program.
If I run sudo apt-show-versions build-essential I get following output:
- build-essential/jaunty uptodate 11.4

Then I proceded to obtain the dependencies on which build-essential package
is based on using following command:
sudo apt-cache depends build-essential
|Depends: libc6-dev
Depends: <libc-dev>
Depends: g++
Depends: make
Depends: dpkg-dev

For libc6-dev, g++, male, dpck-dev packages I cheched their presence on my
system still using the command "sudo apt-show-versions package-name" and I
obtained following results:

libc6-dev/jaunty uptodate 2.9-4ubuntu6
g++/jaunty uptodate 4:4.3.3-1ubuntu1
make/jaunty uptodate 3.81-5
dpkg-dev/jaunty uptodate 1.14.24ubuntu1

This search tell me that probably the build-essential package and all its
dependencies are correctly satisfied.

Next I try to undestand which package contains the stdio.h file. Searching
on the web I learn that the command to use is the following one:

sudo dpkg -S filename

On my machine I get:

sudo dpkg -S stdio.h
libc6-dev: /usr/include/bits/stdio.h
perl: /usr/lib/perl/5.10.0/CORE/nostdio.h
libc6-dev: /usr/include/stdio.h
libstdc++6-4.3-dev: /usr/include/c++/4.3/tr1/stdio.h

I also used the locate command to understand if stdio.h file was installed
on my machine, and the result was:

sudo locate stdio.h

So at this point I think that all things are correctly present on my pc,
but still I still get errors compiling the simply program of Kadhir.

Where do you think the errors is?
Thanks in advance for your help,


David1357 08-24-2009 11:15 AM


Originally Posted by scrat75 (Post 3653617)
Where do you think the errors is?

What is the output of "ls -al $(which -a gcc)"?

scrat75 08-25-2009 07:18 AM

Hi David1357,

unfortunately to solve immediately the problem, I chosed to re-install all my systems... I think that the problem was in a previous installed package that brokes my system.


All times are GMT -5. The time now is 08:49 PM.