PDA

View Full Version : Learning C, getting error when compiling with gcc



oliviacond
November 26th, 2006, 02:24 PM
I have installed gcc from synaptic.
This is the error :


:~/prog/c/learn$ gcc code.c -o code
code.c:1:19: error: stdio.h: No such file or directory
code.c: In function 'main':
code.c:5: warning: incompatible implicit declaration of built-in function 'printf'

meng
November 26th, 2006, 02:30 PM
Try
sudo aptitude install build-essential

then recompile.

I'm no C expert, but the first line of the error code says that gcc can't find the header file (stdio.h) that you want to include. printf is a function of that header file, so the 2nd and 3rd lines follow logically, so to speak.

Hopefully the installation of build-essential will solve the problem.

srix
November 26th, 2006, 03:00 PM
Looks like the development packages are not installed - you probably need libc6-dev, at the very least.

oliviacond
November 26th, 2006, 03:04 PM
problem solved. :)

Ian0107
November 28th, 2006, 06:24 AM
I encountered the same problem, but I couldn't install the so called "build-essential".who can tell me why?
$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package build-essential

hod139
November 29th, 2006, 02:54 PM
What if you do an update first?

sudo apt-get update

az
November 29th, 2006, 03:22 PM
I encountered the same problem, but I couldn't install the so called "build-essential".who can tell me why?
$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package build-essential

If you are not connected to the internet, you need to get the packages from the install cd - they are there, seperate from the live session. Just pop the cd into the drive once you have booted into Ubuntu and the packaga manager will come up. Install build-essential then.