Compiling A C Program: at A Command Prompt Type Then Hit Return To See A List of All Compiler Options
Compiling A C Program: at A Command Prompt Type Then Hit Return To See A List of All Compiler Options
Compiling a C program
The C source code files for the examples in this book are stored in
a directory created expressly for that purpose. The directory
is named “MyPrograms” and its absolute address on Windows is
C:\MyPrograms, whereas on Linux it’s at /home/MyPrograms.
The hello.c source code file, created by following the steps on the
previous page, is saved in this directory awaiting compilation to
produce a version in executable byte code format.
At a command prompt
type gcc --help then hit
Return to see a list of all
compiler options.
l 1 At a command prompt issue a cd command with the path
to the MyPrograms directory to navigate there
15
Because Linux does not by default look in the current directory
for executable files, unless it is specifically directed to do so, it is
necessary to prefix the filename with ./ to execute the program.
You have now created, compiled, and executed the simple Hello
World program that is the starting point in C programming.
All other examples in this book will be created, compiled, and
executed in the same way.