Thread: how to compile a c program in Linux

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Question how to compile a c program in Linux

    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

  2. #2
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214
    Code:
    gcc -o program program.c

  3. #3
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214
    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.

  4. #4
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    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/
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  5. #5
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    But still a common question (but it never annoyed me)
    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?
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2008, 12:08 PM
  2. compile time error in example program
    By dragonlady in forum Windows Programming
    Replies: 3
    Last Post: 01-01-2006, 01:44 PM
  3. compile program?
    By Goosie in forum C++ Programming
    Replies: 9
    Last Post: 06-22-2005, 02:26 PM
  4. Running C program in Linux or Windows
    By kepler in forum C Programming
    Replies: 4
    Last Post: 09-30-2003, 08:31 AM