CS:Eclipse

From Wiki

Jump to: navigation, search

Contents

Using Eclipse in the Linux Lab

Eclipse SDK
Eclipse SDK

Eclipse is a very good Java based IDE (Integrated Development Environment). It is available from http://www.eclipse.org/ and it is free. The College of Engineering Linux lab has Eclipse 3.3.0 available. This IDE can be used for development in Java,C/C++ and Fortran. This tutorial is for Fortran only, however similar steps should work for Java and C/C++.

Running Eclipse

Start Eclipse by following the menus below

 Application > Programming > Eclipse

Eclipse will ask you to select a workspace. A workspace is a directory where Eclipse keeps your projects. You can select the suggested workspace or you can select your own workspace directory.

 The first time you Eclipse is run, it will show you a welcome page. Explore it when you have time.
 This can be accessed using one of the menu selections.

Creating a Fortran Project

Once Eclipse is running follow these steps:

  1. Goto File > New > Project (Alternatively Shift+Alt+N)
  2. Select Fortran > Fortran Project (Then select next)
  3. Enter a project name. Make sure that this name does not have any white spaces and the length of the project name is no more than 31 characters. A white space is a space or a tab character.
  4. On the same screen, select Executable (Gnu Fortran) from the Project Types list. (Then select finish)

Note: If you see a dialog box

Eclipse has now created a Fortran project in your workspace directory under the name you provided in step 3. Note that this directory contains only the project setting files.

Rich made me do it :(

Creating a Fortran Source File

In this section we will create a simple Fortran 90 source file using Eclipse.

  1. Goto File > New > Source File
  2. Enter a source filename. This filename should not contain any white spaces and its length should not be more than 31 characters. The filename should be followed by the Fortran 90 extension .f90 (Then select finish)

This will create a new Fortran 90 file in your project. Click on the Console tab towards the center bottom of the screen. You will see some information there regarding your source file.

A simple Fortran 90 Program

Enter the following program in the source file you have just created:

 program hello
 ! this is a hello world program in Fortran 90
   print *,"Hello World"
   stop
 end

Make sure that you have saved the source file.

Compiling and Executing Fortran 90 Program

If your code syntax is correct, then Eclipse will automatically compile and build your code file and create an executable. This executable is in the Binaries subdirectory. To execute this file

  • Right clicking on the executable file
  • Goto Run As > Run local C/C++ Application

If you see a debug configuration selection screen is up then select the gdb Debugger and select Ok.

Personal tools