Next: Running The Resulting Program
Up: OPERATING SYSTEMS LABORATORY I
Previous: Directories
Contents
Compiling A C Program
- Lets assume there is a file named http://siber.cankaya.edu.tr/OperatingSystems/cfiles/code1.c code1.c that we want to compile. We will do so using a command line similar to this:
$gcc code1.c
- Note that we assume the compiler is called "gcc" (if you're using a GNU compiler). If you're using a Solaris system, you might use "acc", and so on.
- Every compiler might show its messages (errors, warnings, etc.) differently, but in all cases, you'll get a file "a.out" as a result, if the compilation completed successfully.
- You might complain that "a.out" is a too generic name (where does it come from anyway? That's a historical name, due to the usage of something called "a.out format" for programs compiled on older Unix systems).
- Suppose that you want the resulting program to be called "code1". In that case, you could use the following line to compile it:
$gcc code1.c -o code1
Subsections
Cem Ozdogan
2009-05-11