Tell Me What I Need To Know About Compiling ?


TOPICS:

  1. What is the command to use the C Compiler ?
  2. How do I compile my program ?
  3. Are all compilers the same ?
  4. What is "-std1" ?
  5. How do I create a file ?
  6. Is the Compiler and the Editor one Entity ?
  7. Do I need to name my file something special ?
  8. My program had errors, what do they mean ?
  9. How do I fix these errors ?
  10. How do I make my program work ?
  11. What is "a.out" ?
  12. Can I look at "a.out" ? Can I fix "a.out" ?
  13. What is a "core dump" ?
  14. There is a "core" file in my directory. What is it ? Do I need it ?
  15. I need to fix these errors, what do I do ?
  16. COMING SOON......


How do I compile my program ?

For my classes, I required students to use the unix C compiler with the standard flag.

The command you use to access the compiler is:

cc myprogram.c

Back to the Topic Index


Are All Compilers the Same ?

No. Compilers differ for each machine architecture. A program compiled for a MAC differs in Great Detail from the same program compiled for a PC.

To be sure your program works, and that you get credit for it, be sure to compile your program on GLUE. Test it there to be sure it runs correctly. It doesn't matter to your TA or your instructor if it runs at home on your computer. What matters is whether or not it runs on the school computer.

Turn in your TEXT File. Not the compiled program.

Back to the Topic Index


What does -std1 mean ?

This is used when you compile:

cc -std1 myprogram.c

This is the unix command flag that indicates you want the compiler to use ANSI Standard C.

Back to the Topic Index


How do I create the text file ?

You must use one of the unix editors to create your text file. We recommend you use VI or EMACS.

Back to the Topic Index


Is the Editor and Compiler One Big Program ?

NO. Each step is separate and consumes different resources.

Back to the Topic Index


Do I need to name my Text File something special ?

Yes.
Any file that you want to send to the compiler must end with a ".c"

If you try to compile a file named "zippy"

cc zippy
You will get a compiler error.

However, a file named "zippy.c"

cc zippy.c
Will compile. (Assuming you have no other errors)

Back to the Topic Index


What does this error message mean ?

This FAQ does not pretend to know all of the Unix C Compiler Messages. Nor is that the goal of this document. You need to learn to read the compiler error messages.

When you get a compiler error, do your best to figure out what it means. If you try and still do not understand what it's saying, write down the entire compiler error message and bring it, along with your program, to office hours. Your Instructor and your TA will be happy to help you decypher it. Just be sure you write down the whole error message. That will help your Instructor and your TA track down what it means and what happened in your program.

Back to the Topic Index


How do I FIX the Errors in my Program ?

Try to figure out what the error message means. Then re-edit your Text File to fix the errors. You don't edit the executable program that the compiler produces. Edit your Text file to correct the errors and Recompile your program.

Back to the Topic Index


How Do I Make My Program Work ?

The compiler produces the actual running version of the "program" you wrote. It takes your text-written code and produces the machine code that the computer can run to execute your program.

By default the program that the compiler produces is named "a.out". There is no need to change the name of this file. This is not the file you submit to get credit for doing the project. You can change the name of this file (1) at compile time by slightly altering the compiling command or (2) with the move command so as to rename the executable file.

To run the default program created by the compiler ("a.out"), you type:

a.out
or
./a.out
at your "%" prompt.

Your program will run according to the last version of "a.out" that exists. Each time you recompile, the compiler will delete the last version of "a.out" and create a new one. You run your unit tests on the executable version.

Back to the Topic Index


What is "a.out" ?

"a.out" is the default file that the unix compiler calls the executable version of your program that it creates. This is the actual version of your program that "runs".

You do not submit this executable file as your finished project. You submit your original (finished and correct) TEXT file.

Do not print the executable file.

Also see the section on "Making my program work"

Back to the Topic Index


Can I look at "a.out" ? Can I fix "a.out" ?

"a.out" is machine code and not really readable by human beings. (Maybe somewhere out there there's someone who went to great effort to discover how to read unix executable code, but who'd want to?) You don't have to look at the executable file to see your program or fix the errors. You do all your work in the nice, readable text file you wrote your program in. The whole point of having high-level languages like C is so that you can read and write code easily. So re-edit your text file and recompile your program and test it again.

Back to the Topic Index


What's a "Core Dump" ?

A "core dump" is when the operating system terminates your program and dumps the contents of the memory locations associated with your program to a file called "core". Generally speaking, core dumps result from pointer errors or division by zero.

Back to the Topic Index


There is a "core" file in my directory. What is it ? Do I need it ?

The "core" file is created by the operating system when your program encounters a fatal error, and it was terminated prematurely. You do not need to keep core files. You can delete them safely, and without worry.

Not too many people use the core files to find errors anymore. Debuggers exist for that purpose and they are much easier to use and understand.

Back to the Topic Index


[Back to the Top of this Page]


Back to the Top of this page


[Back to the Index]

graphics images Copyright 1998-2003 Elizabeth Fraley HTML code copyright 1998-2003 Elizabeth Fraley. Permission is given to provide these pages in their original, unaltered form online for educational purposes. They may not be republished or included on a CDROM, disk or other media or with any published work without the express permission of the copyright holder (this includes FAQ books).