Question:

How do you compile a program in c using Unix?

by Guest59199  |  earlier

0 LIKES UnLike

I've done a lot of Java programming on Unix, but I'm having difficulty figuring out how to compile a C program. I have Mac OS X and am using Unix. I am just trying to write a very basic "hello world" type program, so I did "emacs hello.c", typed a few lines for the program, saved, and then tried to compile using "cc hello.c" or gcc hello.c". The result was "-bash: gcc: command not found".

Do I have to download something in order to be able to compile, or is there something else I should try? Thanks in advance for any help.

 Tags:

   Report

3 ANSWERS


  1. sound like you don't have the gcc compiler installed. Follow the instructions for installing on your version of unix.

    usually a "command not found" error indicates the program your trying to execute is either not installed or is not in your working directory. in this case I would say its not installed.


  2. You should be able to get gcc for your machine.  As you don't have a C compiler, you'll need a binary distribution.

  3. if you don't have gcc installed, you can't use gcc, obviously.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.