next up previous
Next: Elements of general programming Up: Compiler Previous: Compiler

practice of compilation

  1. Make a directory, and copy /home/progClass/src/immig-emig/hw.c to the directory.
  2. cd into the directory, and try

        gcc hw.c

    In other unix systems, you may need to use cc instead of gcc.

    Image gcc gcc (GNU Compiler Collection) is a free (as speech) C compiler. It is the official compiler in the open source world. There are other commercial compilers, which can produce faster (or slower) programs than gcc. I use gcc as my standard compiler because it supports a wide range of Operating Systems and processors, and it has pretty good performance in general. gcc is installed in most unix and linux computers, it comes with XCode for Mac OS-X, and Windows version can be installed via Cygwin.

  3. You can see that a.out is created. To run (execute) this program,

        ./a.out

    Did you get the expected output? (Some history and jokes about this program.)

  4. To specify the name of the compiled program, use -o option:

        gcc -o helloWorld hw.c


next up previous
Next: Elements of general programming Up: Compiler Previous: Compiler
Naoki Takebayashi 2008-02-11