Emacs makes it easy to compile your C programs. Let's compile our example
program now.
Go to the Emacs window that is displaying the ``joints.c'' program.
There should be a menu named Compile in the menu bar. Pull down that
menu and select the ``Compile This File...'' item. The UNIX command to
compile the C program will appear at the bottom of the Emacs window. It
should look like this:
gcc -Wall -g joints.c -o joints -lm
At this point Emacs is waiting for you to confirm that it should compile the
file. To do this, hit the Enter key. What happens?
Click here for the answer.
Now that the program has been compiled, you can run it. To do this, go to the
UNIX Shell window and use the cd command to navigate into your
examples directory. Then type the name of the compiled version of the
file--in this case, ``joints''. (Remember that the name of the original
C file in this case was ``joints.c''. The name of the compiled program
is generally the same as the name of the original C file, minus the ``
.c'' at the end.)
Type ``joints'' and hit Enter to run the program. What happens?
Click here for the answer.
After the program has finished, you should see a UNIX shell prompt in the
window. You can run the program again by typing ``joints'' again. Try
running the program a few times and type in different angles for the ankle
joint.
Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah