LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-14-2009, 01:31 PM   #1
kadhir
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Exclamation problem in compiling a c program


i have written a simple c program

#include <stdio.h>

int main()
{
printf("Linuxquestions.org\n");
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
 
Old 08-14-2009, 02:03 PM   #2
jrtayloriv
Member
 
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 366
Blog Entries: 1

Rep: Reputation: 44
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:

Code:
sudo apt-get install build-essential
--jrtayloriv

Last edited by jrtayloriv; 08-14-2009 at 02:05 PM.
 
Old 08-14-2009, 02:50 PM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by kadhir View Post
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
/usr/include/stdio.h
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.
 
Old 08-14-2009, 03:21 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,421

Rep: Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590Reputation: 2590
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
 
Old 08-17-2009, 01:16 PM   #5
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by John VV View Post
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.
 
Old 08-22-2009, 10:55 AM   #6
scrat75
LQ Newbie
 
Registered: Aug 2008
Location: Italy
Distribution: Ubuntu 9.04
Posts: 13

Rep: Reputation: 0
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
build-essential
|Depends: libc6-dev
Depends: <libc-dev>
libc6-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
/usr/include/stdio.h
/usr/include/bits/stdio.h
/usr/include/c++/4.3/tr1/stdio.h
/usr/lib/perl/5.10.0/CORE/nostdio.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,

Scrat75
 
Old 08-24-2009, 11:15 AM   #7
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by scrat75 View Post
Where do you think the errors is?
What is the output of "ls -al $(which -a gcc)"?
 
Old 08-25-2009, 07:18 AM   #8
scrat75
LQ Newbie
 
Registered: Aug 2008
Location: Italy
Distribution: Ubuntu 9.04
Posts: 13

Rep: Reputation: 0
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.

Scrat75
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with compiling a c program lifeafterdeath Linux - Newbie 2 11-07-2007 10:16 AM
problem with compiling program Nocker Linux - Newbie 2 05-30-2006 11:28 AM
problem while compiling a lex program sam_cit Linux - Software 1 02-21-2006 03:59 AM
gtkglarea compiling program problem vas_dee Linux - Software 2 03-19-2005 05:23 AM
Problem with compiling my program. Zeth_htp Linux - Newbie 4 04-04-2003 10:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration