Command Format: cc [options] file-list
(See Appendix E for a complete list of options)
When using the cc utility, the following conventions are observed:
1. A filename with the extension of .c indicates a C
language source program.
2. A filename with an extension of .s indicates an assembly
language source program.
3. A filename with an extension of .o indicates an object
program.
The cc utility will take its input from the file or files you
specify on the command line. Unless you use the -o option, it will
store the executable program in a file called a.out.
Sample C Language Source Code Program:
$cat hello.c
main ()
{
printf ("Hello from main!\n\n");
printf ("Calling function1!\n\n");
funct1();
printf ("\t Back from function1!\n\n");
printf ("Calling function2!\n\n");
funct2();
printf ("\t Back from funct2!\n\n");
printf ("That's all!\n\n");
}
funct1()
{
printf ("\t\t Hello from function1!\n\n);
}
funct2()
{
printf ("\t\t Hello from function2!\n\n);
}
Command Format: cc -o output source
output - the name of the executable file
source - the name of the C source code file
The -o option tells cc to tell the link editor to use the specified
name for the output instead of the default a.out.
NOTE: It is not necessary for the -o option to appear after the
cc command. The filename that appears after the -o is
the name of the output file. For example, cc source -
o output is the same as cc -o output source.
Sample Session:
$cc -o hello hello.c
$hello
Hello from main!
Calling function1!
Hello from function1!
Back from function1!
Calling function2!
Hello from function2!
Back from function2!
That's all!
$
Command Format: cc -c main.c funct1.c funct2.c
-c = Compile, but do not load object files. This option
causes cc to compile and/or assemble source code
programs and leave the corresponding object programs
in files with filename extensions of .o.
Sample Session:
$cc -c main.c funct1.c funct2.c
main.c:
funct1.c:
funct2.c:
$ls a.out
a.out not found
$ls -C *.o
funct1.o funct2.o main.o
$
The -c options causes the compilation system to suppress the link
edit phase. This produces an object file or files, in this example
(main.o funct1.o funct2.o), that can be link edited at a later time
with the cc command with no options.
To compile the above program into an executable program, use the
following command at the command line.
Sample Session:
$f77 hello.f
$
Without any options, f77 accepts FORTRAN source code and assembly
language programs that follow the conventions outlined above. It
will compile, assemble, and load these programs to produce an
executable called a.out. The f77 utility outputs the object code
into files with the same base filename (everything before the
period) as the source but with a filename extension of .o.
The a.out stands for assembly output. This is the default.
Sample Session:
$f77 hello.f
$a.out
Hello from main!
Calling function1!
Hello from function1!
Back from function1!
Calling function2!
Hello from function2!
Back from function2!
That's all!
$
NOTE: The a.out file that was created by the f77 utility has
the following permissions:
user - read, write, and execute
group - read and execute
other - read and execute
It is not necessary for you to change the permissions using the
chmod command because the f77 utility set the execute permissions
for you.