Distrubtions of Linux normally have gcc (GNU Compiler Collection) installed by default*. You can verify this by running man gcc, which will open the manual pages for this compiler. These manual pages will explain all the different options for compiling your program. A simple C program shouldn’t require any special options.

An example of how to compile your simple c program, if your program is called hello.c and you want an executable file called hello:

gcc -o hello hello.c

This will create a file called hello in the same directory that you ran the above command. Executing this file will run the C program you’ve compiled.

./hello

Your program should run, and what you told the program to do, should occur. For example, if you created a “hello world” program in C, the terminal might look something like this:

> gcc -o hello hello.c
> ./hello
> hello, world

*Not all distributions have gcc installed by default, or at least it might be omitted when the distro is installed with certain configuration options. Searching for “install gcc on <insert your linux distro>” should provide instructions.

Sources:

  • The C Programming Language 2nd Edition
  • Effective C
  • stackexchange.com