Assuming gcc is installed, the simplest way may be to compose a make file and use the make utility.
Here is an example. Assume you have file program.c that you want to compile and link so that the result is the executable "program".
In the same directory as program.c, place a file called Makefile - the "M" should be uppercase. Create this file with your favorite editor and put the following lines in it:
Code:
# Make file to create the "program" executable
program : program.c
cc -o program program.c
Now, to compile and link in one step, just issue the command:
That's it! Much simpler than manually typing in the whole "cc" command.
BTW, cc is normally aliased to gcc, hence the use of the "cc" command vs. the "gcc" command. Using "cc" instead makes the Makefile more portable, since many *nix systems have a native "cc" and don't need gcc.