16-311 Introduction to Robotics
CRASH COURSE IN COMPILING/DEBUGGING IN THE
CLUSTERS
---------------------------------------------------
- get a SSH client
- some free ones are SSH
and PuTTY. SSH
makes it easy to transfer files to and from your computer to your
andrew space by giving you a pretty graphical interface to use. SSH is on either most or all of the CMU cluster machines, and it's on ALL of the MechE cluster computers.
- write your source code
- you can do this using a text editor like PICO or EMACS,
which
runs on andrew servers. If you're not comfortable with this, you can always write the file in any text editor (i.e., notepad) and then send it over to your andrew space.
- compile
- the easiest way to compile on andrew is to use
gcc. At the prompt, type:
gcc -o (name of your desired executable file) (name of your source
file)"
if you just type in "gcc (name of input file)"
, the gcc will
name your
executable "a.out"
. Odds are, your program won't compile the
first time
you try, but gcc will provide you with a lot of information (line number, what kind of error, etc...). ERRORS will prevent gcc from compiling, WARNINGS will not stop gcc from compiling. You can get extra debugging info by typing "-Wall" as the last argument in the line telling gcc to compile.
example: gcc -o myprogram myprog.c -Wall
will try to compile the source file "myprog.c"
to create the
executable "myprogram"
- more debugging
- even when your program compiles, it may still not work
right. You can run your program on andrew by typing
"./(name of program)"
so, if we use my above example of the program "myprogram"
,
you'd type "./myprogram"
. This will run your code.
TIP: Sometimes, you'll find that you're frequently compiling and running and compiling and running. You can make things easier on yourself by doing it all on one line. This way you can just press the up arrow key, and hit enter, and gcc will recompile your source code, and run the program. You can do this by writing the two commands on the same line separated by a semicolon.
example: "gcc -o myprogram myprog.c -Wall; ./myprogram"
GOOD LUCK!!