PDA

View Full Version : Compile C




stevento
Feb 25, 2008, 11:45 PM
how do i compile C in terminal?
gcc isn't a command
help?



balamw
Feb 25, 2008, 11:49 PM
how do i compile C in terminal?
gcc isn't a command
help?

Did you install XCode? If not, insert your OS X disc and install it.

B

stevento
Mar 8, 2008, 09:00 PM
thanks

if i have a file called hello.c then i enter gcc hello.c to compile it but i dont know what to enter to run the program..?
./ is linux but i dont know what it is here

sammich
Mar 8, 2008, 09:03 PM
If you simply compile with the command 'gcc hello.c' it will create a executable called 'a.out'. To run this enter this into terminal './a.out'

To create a more meaningful name for the exec, use this:

gcc hello.c -o hello (gcc <sourcefile.c> -o <desiredname>)

stevento
Mar 8, 2008, 09:09 PM
oh yeah it works
thanks!!!!!:D