Using Eclipse to Complete 377 projects I. Starting Eclipse Just type: eclipse The environment should be set up already. When the dialog box comes up (after the splash screen), set your workspace to the default. II. Importing a new project 1) Copy the tar file from the web page into your workspace directory and untar it. For instance: cp proj0.tar ~/workspace cd ~/workspace tar xvf proj1.tar 2) Copy the files distributed for the project into the project directory (for isntance the library files) For instance: cp /courses/cs300/cs377/cs377/proj0/* ~/workspace/proj0 3) Import the project into eclipse: 1) File-> Import 2) Existing Project into Workspace (click next) 3) Browse 4) proj0/ 5) ok 6) Finish III. Using Eclipse Editing and Building Code ------------------------- At this point, I'm assuming that you've opened a project successfully. The first time you open the project, eclipse should be in its default perspective. The C/C++ perspective is more useful, so switch to it using Window->Open Perspective->C/C++. In normal C/C++ editing mode, eclipse has 4 main areas. On the left, is the Filesystem/project navigator. This is a simple tree-like file browser. To open a file for editing, simply double-click on it. If the file is of a type unknown to eclipse, you may have to right click on it and tell eclipse to open it with the text editor. In the upper center of the screen is the editing area. This is a fully featured text editor that does syntax highlighting and automatic indentation and all of the good stuff we've come to expect from things like emacs. Additionally, when errors occur during compilation, the left and right margins around the text area will be annotated to pinpoint error-causing code. The left margin will have a red 'X' next to an offending statement (that will itself be underlined in red). Placing the pointer over the underlined statement will bring up a description of the problem (which may not always be helpful). The right margin represents the entire file and clicking on one of the boxes will take you to the error-causing line in the file. On the right hand side of the screen is the Outline/Make Targets pane. The outline lists variables, classes, and other program structure that eclipse can extract from your sources. Although potentially useful, these projects won't grow to a size where such information is really needed. The 'Make Targets' tab is very useful, however. In there, organized by project are located the build targets. To build, just double click on a target. On the very bottom of the screen is the Console. Any output generated by your program, or make as it's building your program will appear in the console. On the very right, there may be a welcome screen. Close it to save screen real estate. IV. Debugging With Eclipse Debugging Code -------------- To debug an executable in eclipse, right click on a file in the navigator and choose 'Debug Local C Application'. For instance, right click on "disk". This will prompt you to chose between GDB Debugger and GDB server. Select GDB Debugger, and say yes to changing perspectives to the debugging perspective. The debugging window is divided into many parts. In the upper left is a panel that shows in which file and function the debugger is currently. To the right of that is a window that has tabs for listing currently active variables (and their values), currently active breakpoints. In the center left of the screen is a code inspection window. This shows where in the code you are, and if you move your mouse pointer over a variable it will show you the current value of the variable. The left margin has a blue dot next to any line with a breakpoint set. To add a breakpoint, simply right click in the margin next to the line of code you want to stop at and select 'toggle a breakpoint'. To the right of this panel is an outline pane. Potentially useful, but not really needed to track down coding bugs in projects of this size. Lastly, at the bottom of the screen is a console. This is where your program and GDB's output will be displayed. To actually debug an application while in this perspective, you set the breakpoints you're interested in and use the buttons in the toolbar of the debug window (they look like VCR controls). Run, stop, step, next, and stepi are all represented. If the program you're debugging needs command-line arguments, click on the debugging button (it looks like a green beetle). Select 'Debug...'. In this window, expand the C/C++ Local configuration. Select the binary you're debugging. Now, to the right of the Configurations selector there will be a tabbed area letting you set all kinds of properties (arguments, environment variables and other goodies). The arguments tab is really the only one that will be of any use in these projects. Eclipse may complain about not being able to find source files. These are likely the ones that are used to compile the libraries I give you. You will just have to skip over these functions in the debugger. Running Code ------------- You can run code in eclipse by right-clicking on the file and selecting 'Run C Local Application'. However, the output will all be redirected to the rather cramped confines of the console window. I'd just run the stuff from the command-line in a suitably sized terminal window.