PDA

View Full Version : how to compile a c program in Linux



xman
03-10-2003, 08:02 AM
Hi guys,

I'm a C newbie. I'm learning C programming under Linux environment. I'd like to know how to compile and run a program programA.c, which #include "programB.h". I've programA.c, programB.h and programB.c all in one directory.

Do I have to compile programB.c first?

I try this command "cc -o programA programA.c" but it didn't work?

Can anyone help, please. Thanks

threahdead
03-11-2003, 03:31 PM
gcc -o program program.c

threahdead
03-11-2003, 04:14 PM
i dont really know the difference between those two.
some time ago i was used to cc. now i got used to gcc.
my two cents. ;)

stautze
03-17-2003, 03:33 AM
here is a page at my school that can explain how it dependencies work and how to create a make file better thatn I can.....
http://www.eng.hawaii.edu/Tutor/Make/

Jaguar
03-18-2003, 10:41 AM
But still a common question (but it never annoyed me) :D
My main.c includes stdio.h, in which function prototype e.g. printf() is declared. But I don't have source code for printf's body.
How does `$ cc main.c' works without compiling body?

If I have several headers.h and several bodies.c, how do I compile like above i.e. `$ cc main.c' only without compiling bodies?