PDA

View Full Version : Error Compiling With GCC



palcal
March 10th, 2007, 05:03 PM
I've never programmed on Linux before, so I've probably made some really simple mistake :P I'm trying to compile a Hello, World application to test the GCC C compiler, and already I'm receiving an error telling me stdio doesn't exist.


$ gcc -ansi -pedantic -Wall -O2 -o hello hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:5: warning: implicit declaration of function ‘printf’
hello.c:5: warning: incompatible implicit declaration of built-in function ‘printf’


hello.c is in a programming directory in my home. Could that be the problem? Though I would of thought GCC would have a PATH variable to the include files.

hod139
March 10th, 2007, 05:08 PM
make sure you install the package build-essential

ssam
March 10th, 2007, 05:12 PM
can you post your hello.c

palcal
March 10th, 2007, 05:17 PM
make sure you install the package build-essential

Great, thanks! What exactly does build-essential consist of that allows GCC to compile my programs when GCC is already installed in Ubuntu?

hod139
March 10th, 2007, 05:26 PM
The package build essential is a meta-package with dependencies on the packages required to build. In particular:
Depends: libc6-dev | libc-dev, gcc (>= 4:4.1.1), g++ (>= 4:4.1.1), make, dpkg-dev (>= 1.13.5)


You were missing the libc-dev package, which containst the C standard headers and libraries.

palcal
March 10th, 2007, 05:27 PM
Okay, thanks again :)