To build an executable from a C source file called demo.c, enter the following command:
% ccmcore demo.c
The driver recognizes demo.c as a valid C source file by its .c extension and invokes the C compiler. The compiler produces an assembly code file, which is then sent to the assembler, which produces an object file which is sent to the linker and linked with the appropriate libraries selected by the driver.
If no errors occur, an ELF format executable file called a.out is created in the current directory. You can rename the output file with the -o compiler driver option.
You can rename the output file with the -o option. For example:
% ccmcore demo.c -o demo
This command creates an ELF format file called demo in the current directory. The filename must immediately follow the -o option.
When a single source file is compiled and linked, all intermediate files are deleted.When more than one file is given to the driver, any object files that are created in the process are not deleted. This is convenient when only one of the files must be recompiled. For example, suppose that you compile several files:
% ccmcore demo.c file1.c file2.c
You then discover that demo.c must be modified. After editing demo.c, you can build the executable with this command:
% ccmcore demo.c file1.o file2.o
Since file1.c and file2.c have not been modified, it is possible to use the object modules file1.o and file2.o created by the previous compilation.
Assembly source files may be input to the compiler driver if the name of the file ends with .s. For example:
% ccmcore demo.s
For assembly source files, the compiler driver first invokes the assembler, then the linker produces the file a.outin the current directory.
If you use the -c option, the compiler driver stops after creating an object file for each source file on the command line. The following command line produces two relocatable object modules, called demo.o and file.o, in the current directory:
% ccmcore -c demo.c file.s
If only one object file is created, you can use the -o option with the -c option to rename the object file. The new name must contain the suffix .o. For example, the following command line creates the relocatable object module newdemo.o in the current directory:
% ccmcore -c demo.c -o newdemo.o
The compiler driver links relocatable object modules into an executable file. If all of the names of the input files to the driver end in.o, the compiler driver invokes the linker only. The following command line links the demo.o, file1.o, and file2.o object modules with the necessary startup code and libraries to produce the file a.out:
% ccmcore demo.o file1.o file2.o