How to install Packages required to compile a C program in Ubuntu 8.04??

Asked by s.arivoli

I keep trying to compile a simple program using the gcc compiler. It won't work. I specifically type in: gcc -o hello hello.c. I get an error reading:
hello.c:2:19: error: stdio.h: No such file or directory
hello.c:4:19: error: stlib.h: No such file or directory
hello.c: In function ‘main’:
hello.c:8: warning: incompatible implicit declaration of built-in function ‘printf’
Even I've tried out "sudo apt-get install build-essential"..... There is no such a file"stdio.h" in usr/include/
Please help me out.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Solved by:
s.arivoli
Solved:
Last query:
Last reply:
Revision history for this message
Alessio Treglia (quadrispro) said :
#1

Are you sure build-install is installed correctly?

That metapackages contains all the necessary dependencies...

Revision history for this message
s.arivoli (arivoli) said :
#2

I tried to install build-essential, but it throws the error that build-essential package not available

Revision history for this message
Alessio Treglia (quadrispro) said :
#3

Mmmm... try with this:

sudo aptitude install build-essential

and post here the result

Revision history for this message
Harvey Muller (hlmuller) said :
#4

s.arivoli,

Also check your Software Sources (assuming Gnome):

    System > Administration > Software Sources

Make sure that all the boxes are checked on the Ubuntu Software tab, and that you have UNCHECKED the Cdrom with Ubuntu box at the bottom.

Thanks,

Harvey

Revision history for this message
s.arivoli (arivoli) said :
#5

after I have executed the command: sudo aptitude build-essential, I'm getting the same errors...................
hello.c:2:19: error: stdio.h: No such file or directory
hello.c:4:19: error: stlib.h: No such file or directory
hello.c: In function ‘main’:
hello.c:8: warning: incompatible implicit declaration of built-in function ‘printf’

Revision history for this message
Alessio Treglia (quadrispro) said :
#6

Can you post here the result of the "sudo apt-get install build-essential" command?

Revision history for this message
Harvey Muller (hlmuller) said :
#7

s.arivoli,

Those errors indicate that the libc development headers have not been installed. Here's how:

    $ sudo aptitude install libc6-dev

That will resolve your missing headers issue.

Please return to Launchpad and mark this question Solved, if this resolves your question.

Thanks!

Harvey

Revision history for this message
s.arivoli (arivoli) said :
#8

Whenever I tried aptitude install build-essential I got his error message:

arivoli@arivoli-desktop:/$ aptitude install build essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
arivoli@arivoli-desktop:/$

Revision history for this message
s.arivoli (arivoli) said :
#9

After this I tried:

arivoli@arivoli-desktop:/$ sudo aptitude install build essential
[sudo] password for arivoli:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
Couldn't find package "build". However, the following
packages contain "build" in their name:
  xorg-build-macros
Couldn't find any package matching "essential". However, the following
packages contain "essential" in their description:
  perl-base groff-base python-minimal coreutils startup-tasks im-switch system-services python2.5-minimal
  gstreamer0.10-plugins-base-apps gnome-panel gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-0
Couldn't find package "build". However, the following
packages contain "build" in their name:
  xorg-build-macros
Couldn't find any package matching "essential". However, the following
packages contain "essential" in their description:
  perl-base groff-base python-minimal coreutils startup-tasks im-switch system-services python2.5-minimal
  gstreamer0.10-plugins-base-apps gnome-panel gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-0
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
arivoli@arivoli-desktop:/$

Revision history for this message
s.arivoli (arivoli) said :
#10

I tried this one too...........

arivoli@arivoli-desktop:/$ apt-get install build-essential
E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
arivoli@arivoli-desktop:/$

Revision history for this message
s.arivoli (arivoli) said :
#11

Finally I tried this one:

arivoli@arivoli-desktop:/$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package build-essential
arivoli@arivoli-desktop:/$

Revision history for this message
s.arivoli (arivoli) said :
#12

At last I tried this one:

You may have to enable your universe and multiverse repositories.
You can do that using Menu->System->Administrator->Software Sources and in the Ubuntu Software tab enable the 2nd (universe) and 4th entry (multiverse).
After closing, open a terminal, and type: sudo apt-get update
And after that: sudo apt-get install libc6-dev

now its working for .c, .cpp files too.... thanks Cesare Tirabassi

I got this info from: https://answers.launchpad.net/ubuntu/+question/5953

Revision history for this message
s.arivoli (arivoli) said :
#13

Thank you Harvey Muller. Thank you everybody.....