Page 1 of 19 UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared By: Harald Gjermundrod Table of Contents 1 EASY INSTALLATION... 2 1.1 DOWNLOAD... 2 1.2 INSTALLING... 2 2 CUSTOMIZED INSTALLATION... 5 2.1 INSTALL JAVA JDK... 5 2.1.1 Download... 5 2.1.2 Installing... 5 2.2 INSTALL GCC COMPILER KIT... 5 2.2.1 Download... 5 2.2.2 Installing... 6 2.3 INSTALL THE UNIC ECLIPSE DISTRIBUTION... 8 2.3.1 Download... 8 2.3.2 Installing... 9 2.4 OPTIONAL SETTINGS... 10 2.4.1 Setting the System Path... 10 3 CREATE A HELLOWORD APPLICATION IN ECLIPSE... 14
Page 2 of 19 1 Easy installation You can install the Wascana distribution of Eclipse, which contains everything you need to develop C++ applications. 1.1 Download You can download Wascana (wascana-1.0-setup.exe) from: http://code.google.com/a/eclipselabs.org/p/wascana/ 1.2 Installing There are 5 steps that you must follow to install the Wascana Eclipse Distribution Step 1: Run (double-click) the downloaded file. Figure 1: Step 1 Installing Wascana
Page 3 of 19 Step 2: Just click Next > Figure 2: Step 2 Click Next > Step 3: The default directory should be C:\Wascana It is safest if you don t modify this. Just click the Next button. If you change this, make sure that there are no spaces in any directory name. Figure 3: Step 3 Select directory and click Next >
Page 4 of 19 Step 4: The default selection is ok, so just click the Install Button Figure 4: Step 4 Installing Wascana Step 5: Just click Next > at the end of the installation Figure 5: Step 5 Installing Wascana
Page 5 of 19 2 Customized Installation This guide is for the Windows family of operating systems. The guide below should work for Windows 7, Windows Vista and Windows XP For 32-bit or 64-bit versions of Windows: GCC compiler kit like: tdm-gcc-4.5.1.exe. You can download this for free from: http://tdm-gcc.tdragon.net/download Java JDK 7 (32-bit version): jdk-7u7-windows-i586.exe. You can download this for free from: http://www.oracle.com/technetwork/java/javase/downloads/index.html UNic Eclipse distribution (32-bit version): eclipse-32.zip. You can download this for free from: http://www.cs.unic.ac.cy/harald/teaching.html Note 1: In case you install the 64-bit version of Java, make sure that you make the 32-bit the default JVM. 2.1 Install Java JDK 2.1.1 Download You should download the latest version of the JDK from: http://www.oracle.com/technetwork/java/javase/downloads/index.html The current version is: jdk-7u7-windows-i586.exe (32-bit)) 2.1.2 Installing Double click on the executable and apply all the default options in the install wizard that starts. 2.2 Install GCC Compiler Kit 2.2.1 Download You should download the latest version of the Bundle Installer from: http://tdragon.net/recentgcc/ The current version is: tdm-gcc-4.6.1.exe and tdm64-gcc-4.6.1.exe (64-bit)
Page 6 of 19 2.2.2 Installing There are 6 steps that you must follow to install the GCC Compiler Kit Step 1: Run (double-click) the downloaded file to install the GCC Compiler Kit. Figure 1: Step 1 Installing GCC Step 2: Uncheck the Check for updated files selection box and click the Create button Figure 2: Step 2 Installing GCC
Page 7 of 19 Step 3: The default directory should be C:\MinGW You must use this, so don t modify it. Just click the Next button. Figure 3: Step 3 Installing GCC Step 4: The default selection is ok, so just click the Install Button Figure 4: Step 4 Installing GCC
Page 8 of 19 Step 5: After successful installation just click on the Next button. Figure 5: Step 5 Installing GCC Step 6: In the final wizard page just click on the Finish button. Figure 6: Step 6 Installing GCC 2.3 Install the UNic Eclipse Distribution 2.3.1 Download You should download the latest version of the UNic Eclipse distribution from: http://www.cs.unic.ac.cy/harald/teaching.html or you can copy it from the CD.
Page 9 of 19 2.3.2 Installing There are only three steps needed to install Eclipse. Just copy the archive file (eclipse.zip or eclipse.rar) to your home directory and then unzip it. The third step is optional, but you can create a shortcut on your desktop. Step 1: Copy eclipse.zip or eclipse.rar to your home folder and unzip it. Figure 7: Step 1 Installing Eclipse Step 2: Right-click on the eclipse.rar or eclipse.zip file and select Extract Here. Figure 8: Step 2 Installing Eclipse
Page 10 of 19 Step 3: Inside the Eclipse folder right-click on the eclipse.exe file and select Send to -> Desktop (create shortcut). Figure 9: Step 3 Installing Eclipse 2.4 Optional Settings If you want to use the command line prompt (cmd) to compile your programs, then you will have to modify your path environment variable. If you don t know what this means you SHOULD NOT do the following!!! 2.4.1 Setting the System Path The GCC package is installed in the following folder: C:\MinGW\. The executable is located within the \bin folder in the installation directory. The system path must therefore be modified to point to this directory. This is done by following these steps:
Page 11 of 19 Step 1) Go to: Control Panel -> click on System-> click on Advanced system settings (see Figure 20) Figure 20: Advanced system settings
Page 12 of 19 Step 2) Click on Environment Variables -> in the dialog that opens click on the line that starts with Path (see Figure 21) Figure 21: Environment Variable
Page 13 of 19 Step 3) Click on Edit -> scroll to the end of the line, and then insert the following: ;C:\MinGW\bin (see Figure 22) NOTE 1: MAKE SURE THAT YOU DON T DELETE ANYTHING! IN CASE YOU DO, CLICK ON THE Cancel BUTTON AND DO IT AGAIN NOTE2: MAKE SURE THAT YOU START WITH THE SEMICOLON ; Figure 22: Setting the Path
Page 14 of 19 3 Create a HelloWord Application in Eclipse Once you have installed the GCC compiler kit and the UNic Eclipse distribution you are ready to start to develop software. There are three major steps that you must follow: 1) Create a C++ Project 2) Write the Source Code 3) Build and Run the Application The steps below will show you have to create a helloworld application. Step 1: Select Workspace folder, i.e. where you will store your projects. Click the OK button after you have selected a folder. Figure 10: Step 1 Develop HelloWorld Application in Eclipse
Page 15 of 19 Step 2: Close the Welcome Screen. Do this by clicking on the X next to the Welcome tab Figure 11: Step 2 Develop HelloWorld Application in Eclipse Step 3: Create a new Project by selecting: File -> New -> Other Figure 12: Step 3 Develop HelloWorld Application in Eclipse
Page 16 of 19 Step 4: Select C/C++ -> C++ Project and then click the Next Button. Figure 13: Step 4 Develop HelloWorld Application in Eclipse Step 5: First give your project a name, then select Executable -> Hello World C++ Project and then click the Next Button. Figure 14: Step 5 Develop HelloWorld Application in Eclipse
Page 17 of 19 Step 6: If you want, you can fill in your name as Author and a Copyright notice. Then you click on the Finish Button. Figure 15: Step 6 Develop HelloWorld Application in Eclipse Step 7: You may be asked the following question; if so click on the Yes button. If you don t want to see this message again select the Remember my decision. Figure 16: Step 7 Develop HelloWorld Application in Eclipse
Page 18 of 19 Step 8: You can now modify the source code, by opening the source file in the Project Explorer: ProjectName ->src ->sourcenamefile.cpp. Figure 17: Step 8 Develop HelloWorld Application in Eclipse Step 9: After you are done with the coding, click on the Green start button in order to run your project. The output of your program is shown in the Console view at the bottom. Figure 18: Step 9 Develop HelloWorld Application in Eclipse
Page 19 of 19 Step 10: To compile the project during development you click on the hammer icon. If you have compile errors those will be shown in the Problems view at the bottom. In addition there are red circles with an X at the code lines with a compile error. Figure 19: Step 10 Develop HelloWorld Application in Eclipse