C Language Compile
since 28 April, 1999 last modified 28 April, 1999
Compile Option
- cc -o execution_file_name
makes execution_file_name excutable file.
an example : cc world.c -o world- cc -c source_file_name.c
makes source_file_name.o object file.
an example : cc -c world.cModular Compile
If there are two C source files to be complied to a exe file, the following steps can make it.
- Make each object files
cc -c korea.c => korea.o
cc -c japan.c => japan.o
- Compile the files to an execuable file.
cc korea.o japan.o -o eastasia => eastasiaCompile with a Makefile
The modular compile can be done with the following makefile.
eastasia : korea.o japan.o
[TAB] cc korea.o japan.o -o eastasiaAn explanation of the Makefile
- A : B (ex. eastasia : korea.o japan.o) defines the depandancy between A and B, A is made from B, so Make utility checks the modification time of the two files and if the time of B is more recent, It will run the below script.
If the B is missed, the below excustion script will run without checking a condition (The 'cleanup' in the below code is an example.).cleanup :
[TAB] -rm korea.o japan.ousage : 'make cleanup' deletes all the object files.
- execution script (ex. cc korea.o ...) the depandancy is cheked then, the utility runs the script.
Macros in Makefile
Korean Engineering Databases © copyright Namchul Do, 1999