Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:making-a-small-project-in-eclipse [2015/01/07 15:52] (current)
ryancha created
Line 1: Line 1:
 +=Introduction=
  
 +Eclipse is a large and sophisticated tool for building C++ programs. Try to stick to the basics to begin with. Eventually you should wander around a bit to see what is there, but especially if you are new to programming,​ you may not want to play with too much early on. The problem is that Eclipse likes to remember what you have done in the past, this can be very handy for repetitive tasks, but it can cause problems in that you may do something today in the context of just playing with it, that it will remember later in the semester. Thus, later you might be confused why it is behaving differently for you than for your peers; you having long since forgotten the playing-around you did today.
 +
 +There are parts of Eclipse that are like Microsoft Word. You can edit and save files just like in Microsoft Word. To me, the biggest difference is that eventually we will not be able to reasonably organize all of our work into a single file. Eclipse will allow us to put a set of files into a project, much like you might if you were making a book in Microsoft Word. If you were writing a book using Microsoft Word you might make one file for each chapter or section. Likewise Eclipse will allow you to make one file for each part of your program. The difference is that Eclipse requires you to make a ''​project''​ and the create files within that project, even if your project requires only one file.
 +
 +Note also that the Computer Science lab computers use a network file server, obviously this is nice since you can log on to any computer and still see your work, but I noticed when I went through this process on a clean account that there are sometimes some long pauses as the computer or Eclipse sets things up for the first time. Based on my experience, make sure you have some time and are in a patient frame of mind the first time you log in and try to do something. It is best not to have your spouse or friends waiting for you in the parking lot.
 +
 +
 +=Installing Eclipse=
 +
 +It is not necessary to install Eclipse on your own machine because the lab computers are available, but in case you wanted to be able to work on your projects at home, here is a tutorial for installing Eclipse:
 +
 +
 +== Before installing eclipse ==
 +
 +
 +Eclipse requires another program in order to compile C++ code. To get it, go to [http://​cygwin.com/​install.html] and press the “setup.exe” link, then run the downloaded file.
 +
 +[[File:​Cygwin_download.JPG]]
 +
 +
 +Click through the various prompts until you reach the “Choose a Download Site” window. Any of them should work, so just click one and press next.
 +
 +
 +[[File:​Cygwin_mirrors.JPG]]
 +
 +
 +Press OK to the Setup alert. On the index page, search for or browse for the following '''​four'''​ packages (they will be under the “devel” tab): “''​gcc-g++:​ C++ compiler'',​” “''​gdb:​ The GNU Debugger'',​” "''​automake 1.9...''"​ and “''​make:​ The GNU version of the ‘make’ utility''​.” Make sure you select each of them by clicking on the word “Skip” next to them. 
 +
 +
 +[[File:​Cygwin_packages.JPG]]
 +
 +
 +When you’re finished with that, press next, accept at the next window, and wait for them to download and install.
 +
 +While you’re waiting, you need to edit your Path environment variable. To do this, either search at the start menu for “environment” or follow these steps. Right click “Computer” or “My computer” on the start menu and click properties. Select “Advanced system settings” on the left of the screen.
 +
 +
 +[[File:​Env_vars_1.JPG]]
 +
 +
 +Select Environment Variables
 +
 +
 +[[File:​Env_vars_2.JPG]]
 +
 +
 +At the window that pops up, scroll to Path under “System variables,​” and press Edit (Make sure that you hit the right one, there are two edit buttons).
 +
 +
 +[[File:​Env_vars_3.JPG]]
 +
 +
 +At the end of the list of values, insert a semicolon and insert “''​C:​\cygwin\bin''​” (without the quotes). Press OK.
 +
 +
 +[[File:​Path_var.JPG]]
 + 
 +
 +'''​YOU WILL HAVE TO REBOOT BEFORE THIS WILL TAKE EFFECT. RESTART YOUR COMPUTER BEFORE TRYING TO RUN ECLIPSE.'''​
 +
 +== Getting eclipse ==
 +
 +
 +*'''​IMPORTANT'''​ – I was unable to get console output with the 64-bit version of eclipse. Even if your computer is 64-bit, I recommend that you download/​install the 32-bit version. You shouldn’t encounter any problems if you run a 32-bit eclipse on a 64-bit machine. If you do manage to get the 64-bit version working properly, please update this tutorial accordingly.
 +
 +First go to the URL [http://​www.eclipse.org/​downloads/​]. Click the “Windows 32 bit” link next to “Eclipse IDE for C/C++ Developers (includes Incubating components).”
 +
 +
 +[[File:​Eclipse_download_page.JPG]]
 +
 +
 +At the following page, you can either press the green icon to download a zip archive, or press the Genuitec link if you want an installer.
 +
 +
 +[[File:​Eclipse_download_selection.JPG]]
 +
 +
 +If you choose the Genuitec link, you will most likely have to press “More Eclipse Packages” before you can see the link entitled “Eclipse for C/C++  (Eclipse Indigo 3.7)”
 +
 +
 +[[File:​Genuitec.JPG]]
 +
 +
 +If you chose the zip archive, simply extract the archive to wherever you want it, then run eclipse.exe. I recommend creating a shortcut that you can place on your desktop.
 +
 +If you chose the installer, simply follow the prompts to install eclipse wherever you want. Remember to choose the 32-bit option.
 +
 +=Starting Eclipse=
 +
 +I assume you are comfortable starting programs in Microsoft Windows. The only real question is "Where is Eclipse!"​ There are several ways to get there but I started at the Windows start button, like:
 +
 +[[File:​1-Start.png]]
 +
 +
 +
 +Hovering the mouse pointer over "All Programs"​ yields a bunch of options, like:
 +
 +[[File:​2-eclipsegroup.png]]
 +
 +
 +
 +Click on the Eclipse folder to get to Eclipse itself, like:
 +
 +[[File:​3-runeclipse.png]]
 +
 +Then click on Eclipse to start it.
 +
 +
 +
 +You will see a slash screen for a while and then it will ask you where to put your projects, like:
 +
 +[[File:​4-runeclipse.png]]
 +
 +
 +
 +I just went with the default location, so I just clicked "​Ok"​. Note that it will ask you this every time it starts up if you do not click the check box. I left it unchecked the first few times I started Eclipse and then got irritated and checked it.
 +
 +=Making a Project in Eclipse=
 +
 +Eventually you will see the Eclipse start screen. I went straight to the workbench which can be accessed by the icon in the upper right-hand corner, as shown here:
 +
 +[[File:​5-eclipseinitial.png]]
 +
 +
 +
 +This brings you to an empty workbench which looks like (note that hovering the mouse pointer over an icon tells you what it will do, which you can see in this picture. Ignore the "open task" tip which was accidentally captured here):
 +
 +[[File:​6-workbench.png]]
 +
 +
 +
 +From here you can make a new project by clicking on the "​File",​ "​New",​ "​Project..."​ menu item as shown here:
 +
 +[[File:​7-newproject.png]]
 +
 +
 +
 +I just make a C++ Project.
 +
 +
 +I named my project "​helloproject"​ and clicked "​Finish"​.
 +
 +=Putting Something in your Project=
 +
 +We will talk about classes more later, but for now think of a class as a sub-container or file you will need for each part of your project. ​ In this case we will only have one. Make a class for your project by right clicking the project folder, choosing new, then choosing class.
 +
 +You will asked to name the class, I called it "​Hello"​.
 +
 +It will automatically make a header file and a source file, and will automatically generate some basic stubs.
 +
 +You may make a mistake in typing. If so, eclipse may mark the left-hand margin with a red mark indicating that it thinks something is wrong. If you see such a mark, look carefully at the line itself and at the lines above and below. Note that as you type you may see such marks simply because you have not finished typing everything, no harm done, just finish typing.
 +
 +=Running Your Program!=
 +
 +And run it by clicking on the green "​play"​ arrow (note that hovering the mouse pointer over the icon tells you what it will do, but the mouse pointer itself was not captured in the picture).
 +
 +After it runs you will see the results in the pane at the bottom.
 +
 +For your lab, use file-new to make a new project, I do not recommend modifying the existing project. Leave working stuff alone.
 +
 +When you are done you can exit in the usual way.
 +
 +=Backup=
 +
 +You should also think about a back-up strategy. Programming,​ like writing, is often filled with moments where you wish you could go back to what you had last night, or the day before. I strongly recommend making a copy (actually a series of copies) of your workspace on a usb drive every now and then with a new name like "​workspace-copy-2010-11-04"​.
cs-142/making-a-small-project-in-eclipse.txt · Last modified: 2015/01/07 15:52 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0