PDA

View Full Version : How to use GCC?



ashokmkd
December 25th, 2008, 07:13 AM
I have c programming experience in windows but i am new to linux.
I installed Ubuntu 8.04 then made a sample.c in home directory and typed in terminal
-> gcc -c sample.c

output says stdio.h is not found.
similar is the case with all header files.
Shall i install some additional libraries?

wd5gnr
December 25th, 2008, 07:22 AM
What does sample.c look like? Do you have a /usr/include/stdio.h? Have you installed the build-essentials package?

To compile a simple program like this you probably want:

gcc -o sample sample.c

But your command should have worked (producing sample.o which still needs linking).

ashokmkd
December 25th, 2008, 07:25 AM
its a simple helloworld example i wrote for testing gcc. i haven't installed any packages. i searched the filesystem but stdio.h is not there.

croto
December 25th, 2008, 07:29 AM
Probably you're missing the build-essential package, it provides compilers, headers, that you'll need to compile anything. To install type:


sudo apt-get install build-essential


for mor info check:https://help.ubuntu.com/community/CompilingSoftware

ashokmkd
December 25th, 2008, 07:31 AM
thank you both. let me try it

monkeyking
December 25th, 2008, 08:28 PM
consider using other compiler options like

-Wall this will turn on all warnings
-pedantic refused to compile "bad" code
-ansi follow the standard

slavik
December 26th, 2008, 03:07 AM
Have you looked at the stickies? one of them contains a FAQ that tells you all of this and so much more.