Reputation: 47
I am having trouble compiling and running my C program. What are the commands?
My code is:
#include <stdio.h>
int main(){
printf("Hello World!\n");
exit(0);
}
I tried compiling with
gcc -o hello.c
only to be unsuccessful. I am using a Mac terminal, if that matters.
Upvotes: 0
Views: 55
Reputation: 134276
In gcc
, option -o
is used to specify a custom output filename. The immediate next argument should be the file name.
-o file
Place output in file file. This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.
A simple revised command will be
gcc -o hello hello.c
where, hello
is the name of the binary.
You can check the online gcc manual for more info.
Upvotes: 3