Although you might be able to understand C source code (at least, after reading this book you will be able to), your computer can't. A computer requires digital, or binary, instructions in what is called machine language. Before your C program can run on a computer, it must be translated from source code to machine language. This translation, the second step in program development, is performed by a program called a compiler. The compiler takes your source code file as input and produces a disk file containing the machine language instructions that correspond to your source code statements. The machine language instructions created by the compiler are called object code, and the disk file containing them is called an object file.
NOTE: This blog covers ANSI Standard C. This means that it doesn't matter which C compiler you use, as long as it follows the ANSI Standard.
Each compiler needs its own command to be used to create the object code. To compile, you typically use the command to run the compiler followed by the source filename. The following are examples of the commands issued to compile a source file called RADIUS.C using various DOS/Windows compilers:
| Compiler | Command |
| Microsoft C | cl radius.c |
| Borland's Turbo C | tcc radius.c |
| Borland C | bcc radius.c |
| Zortec C | ztc radius.c |
To compile RADIUS.C on a UNIX machine, use the following command:
cc radius.c
Consult the compiler manual to determine the exact command for your compiler.
If you're using a graphical development environment, compiling is even simpler. In most graphical environments, you can compile a program listing by selecting the compile icon or selecting something from a menu. Once the code is compiled, selecting the run icon or selecting something from a menu will execute the program. You should check your compiler's manuals for specifics on compiling and running a program.
After you compile, you have an object file. If you look at a list of the files in the directory or folder in which you compiled, you should find a file that has the same name as your source file, but with an .OBJ (rather than a .C) extension. The .OBJ extension is recognized as an object file and is used by the linker. On UNIX systems, the compiler creates object files with an extension of .O instead of .OBJ.
“You can chain me, you can torture me,
you can even destroy this body,
but you will never imprison my mind.”
No comments:
Post a Comment