Let's jump right in.
![]() |
Working in a terminal window requires knowledge of command-line commands, such as 'cd', 'ls', |
- Select a location on your system (or create such with a file manager).
- Open a terminal window; Navigate to that location.
- Open a text editor; Copy then paste the boxes below into your editor.
- (Arrange the terminal & text editor windows so both are seen side-by-side.)
- Save the first block of code below as 'goc'. Save the second as 'main.c'.
- In the terminal window, make shell script 'goc' executable: "chmod +x goc"
- Invoke the compile script with the line: "./goc pgm1"
- List the files present in the terminal. There should be 3: goc, main.c, pgm1.
- Invoke the newly-created program with './pgm1'
#!/bin/bash
# invoke this script with desired name of executable
# 'C' source code is expected in file 'main.c'
# flag the compiler to provide more error and warning checks
pgmname=$1
gcc main.c -Wall -o $pgmname
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return(0);
}
Converting the source code for our 'C' program, to result in an executable program, can involve steps that repeat in a somewhat circular fashion. Generally, the work flow takes this pattern: