PDA

View Full Version : problem compiling Hello World!



AnotherWay83
January 2nd, 2007, 12:30 AM
lol...so yeah im a n00b to ubuntu!! i just tried to get my very first hello world program to compile using gcc, and here is the code:

#include <stdio.h>

int main() {
printf("Hello World!");
return 0;
}

and I tried compiling it using 'gcc -o test test.c' but it complained that it couldn't find stdio.h....i think i need to specify where the includes are, but where are they? i dont know myself! someone pls. hellllllllllppppppppppppp

fanks!

chipdip
January 2nd, 2007, 12:32 AM
Try to remove the .h on the include, so it looks like:
#include <stdio>
that should fix it. I dont believe that you need the .h at the end in Linux.

AnotherWay83
January 2nd, 2007, 12:41 AM
hi,

thanks for the reply, i tried that and it still doesn't work. it says 'error: stdio: No such file or directory'

what should i do???

wehttamb
January 2nd, 2007, 04:06 AM
Hi

I also have the same problem. I think we need to install stdio but i dont know how.
:confused: PLEASE HELP!!!:confused:

wehttamb
January 2nd, 2007, 04:16 AM
:) :) :) I just found someone else who had the same problem and got an anser. We have to install another thing. have a look at the post http://ubuntuforums.org/showthread.php?t=325742&highlight=stdio

I am installing it now.:)

ElysianEagle
January 2nd, 2007, 07:31 AM
hi,

thanks for that...so i did the updates and it works!! many many fanks...and i guess we do have to add the ".h" because otherwise it complains that it cannot find the file

hod139
January 2nd, 2007, 03:30 PM
You keep the .h in the header, but make sure you install the package


build-essential


which will actually install the missing headers. The only time you drop the .h is for certain standard C++ includes, never for a C include.

invalid
January 3rd, 2007, 02:19 AM
It sounds like you all only installed the compiler, but no other necessary files for building and compiling software.

sudo apt-get install build-essentialwill install all the important files for you.