Find the answer to your Linux question:
Results 1 to 7 of 7
How do you compile basic ".c" files through command console? I have gcc 3.3.4. What are the commands?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie exploder's Avatar
    Join Date
    Jun 2005
    Location
    127.0.0.1
    Posts
    164

    Compiling C files


    How do you compile basic ".c" files through command console? I have gcc 3.3.4. What are the commands?
    Registered Linux User#394486

  2. #2
    Linux User
    Join Date
    Oct 2004
    Location
    Serbia&Montenegro
    Posts
    281
    Well, the basic command that you use is:

    Code:
    gcc [filename].c
    But some libraries need additional options.
    Linux registered user #358842
    Human knowledge belongs to the world.

  3. #3
    Linux Guru AlexK's Avatar
    Join Date
    Feb 2005
    Location
    Earth
    Posts
    3,379
    type into a terminal:
    Code:
    gcc -Wall something.c
    the -Wall option specifies all warnings, handy for keeping to the standards and letting you know where errors are in your code. replace something.c with name of the c file.
    Life is complex, it has a real part and an imaginary part.

  4. #4
    Linux Newbie exploder's Avatar
    Join Date
    Jun 2005
    Location
    127.0.0.1
    Posts
    164
    Now i can compile the file, but how to view the output?
    Registered Linux User#394486

  5. #5
    Linux Guru AlexK's Avatar
    Join Date
    Feb 2005
    Location
    Earth
    Posts
    3,379
    run:
    Code:
    ./a.out
    if you don't like calling it ./a.out, compile it with this process:
    Code:
    gcc -Wall -o hello hello_world.c
    where hello_world.c is the name of the code and hello is the name of the executable. and to run this, enter:
    Code:
    ./hello
    Life is complex, it has a real part and an imaginary part.

  6. #6
    Linux Newbie
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    168
    The command specified above will generate a file called a.out.

    To execute the a.out file, issue the command ./a.out

    If all goes well, you will see the output on the console. If you would like to change the name from a.out, issue the command mv a.out [newfilename]

    Jeff
    Registered Linux User #391940

  7. #7
    Linux Newbie exploder's Avatar
    Join Date
    Jun 2005
    Location
    127.0.0.1
    Posts
    164
    Great! Thanx a lot guys. Everything is working well
    Registered Linux User#394486

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •