C

This is a discussion on C within the Linux Programming forums, part of the Platform Specific Boards category; Wow. Thats a broad title. Anyways. I need help compiling and executing my c files through command prompt. What I ...

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    C

    Wow. Thats a broad title. Anyways. I need help compiling and executing my c files through command prompt. What I did.

    vi new.c
    **inserted tons of code***
    :wq
    gcc -c new.c
    **new.o appears**



    Now what do I do? I don't know how to link it into an executable. Someone told me something about make, and I don't know what to do. Can someone just tell me the other command to link it into an exec. file?
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  2. #2
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    Code:
    $ gcc -o new new.c
    $ ./new
    the first line produces the executable, the second executes it, -c tells gcc not to link the object file, so you won't get an executable in that case.

  3. #3
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    however, "gcc -c" is what you would use if you have a multiple file project, then you would link them afterward.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21