Using IDE's
Using IDE's
- If installing at home, make sure that you install gnat first
- Several IDE's are available:
- AdaGide: Simple and powerful
- GPS: More complex and more powerful
- JGrasp: Simple
- GnatBench on Eclipse
hello.adb
- Here is a sample Ada program to compile and run, Hello World:
with ada.text_io; -- Tell compiler to use i/o library
use ada.text_io; -- Use library routines w/o fully qualified names
procedure hello is
begin
put("Hi 320");
end hello;
Filename: hello.adb
Using AdaGIDE
- AdaGIDE is a simple IDE, but it only works in Windows
- It provides autocompletion and access to the gdb debugger
- AdaGIDE is Windows only
- Available on campus at: Start/Programs/RUCourseSW/CST/Ada IDE/adagide
- May not be available on machines with smaller hard drives
- Steps to create, compile, and run
- Create w/ File/New
- Enter program
- Save to file hello.adb with File/Save
- Compile with Compile/Build (F3)
- Run with Run/Execute (F4)
- Fixing AdaGIDE: The 2018 version of AdaGIDE does not compile correctly with the lastest gnat compiler.
Compiling fails with an error message that says that "gnat05" is not a valid option.
To fix adagide, use an editor that handles hex correctly (such as vim) and follow these steps (for vim):
- Locate the adagide executable (ie adagide.exe), probably in Program Filex (x86)/adagide
- Make a backup of adagide.exe in case something goes wrong
- Open adagide.exe with vim
- Change gnat05 to gnat12 throughout the file: :%s/gnat05/gnat12/
- Save the file: :wq
Using GPS (Simple Instructions)
- To use GPS, in addition to your main procedure, you need a project file that gives the name of the
main procedure
- For example, to create main procedure
hello
in file
hello.adb
do the following:
- Use an editor to create a project file called
hello.gpr
containing these lines:
project hello is
for main use ("hello");
end hello;
- Save this file (ie
hello.gpr
), exit the editor, and then click on
hello.gpr
- When GPS starts, create
hello.adb
, as follows:
- Create a new file using the New icon or File/New
- Save this file, using the name
hello.adb
(make
sure to include the .adb
)
- After entering your code you can Build and Run your program
- Once your source file (eg
hello.adb
) exists, clicking
on hello.gps
will run gps
and automatically load hello.adb
Using GPS (More complex instructions)
- GPS is a more complex and more powerful IDE
- It provides a powerful interface to the debugger and has identifier completion
- GPS has versions for Windows and Linux
- GPS is based on projects. A project is defined by a project file (eg
yourProj.gpr) which
contains information such as
- The files that are used by the project
- The directories where those files are stored
- Which file is the Main file (ie where execution begins)
- What compiler options are to be used during compilation
- Steps to create a project and to create, compile, and run a program file
- Run GPS from the Start menu
- On the startup screen,
select "Start with default project in directory:", set the directory where you want to store the
project, and press OK
- Create your program by selecting File/New and then entering the program.
- To get syntax highlighting and indenting when you first type your program,
you should save the (empty) file
so that GPS knows that this an Ada file. To save, use File/Save and save it as yourName.adb.
- Set your program as the main file by doing Project/Edit Project Properties and select the tab for
"Main files", and then select Add to add your file as the main program
- Compile your program with Build/Make/yourFile.adb
- Run your program with Build/Run
- If you want to rename your project, you can change the name under the
General tab of Project/Edit Project Properties, and then save the new project
file. The old project file will still exist.
Creating a new GPS project using a wizard
- As an alternative to the Simple or Complex Instructions above, you can
use a wizard
- Select "Creating a new project with wizard"
- Select Project/New Project
- Steps with the wizard (press "Forward" after each step, and watch your progress in the left panel):
- Select "Single Project"
- Choose a name for your project (eg project1) and the directory
where the project will be created (eg on your desktop)
- The project will consist of a project file (eg project1..gpr, your program (eg hello.adb), and the files that result from compilation (eg hello.o, hello.ali, hello.exe)
- Accept the choice of the language Ada
- Accept the VCS screen
- Accept the default source directory (eg your deskop)
- Enter the build directory (eg Desktop) - this is where .o, .ali, and .exe files will appear. (You may press apply at this point or continue with the remaining screens)
- Accept the blank "Main files" screen
- Accept the default "Naming scheme"
- Accept the default switches
JGrasp
- JGrasp is an interesting IDE that provides various visualizations of
your program. Handles Ada and Java.
Using Gnatbench on Eclipse
- Use menu item
Project/Build Current Project
or Project Rebuild Current Project
to check for syntax errors
and generate executable code
- The Build All icon checks for syntax errors, but only seems to generate
executable code the first time it is used
- The
Project/Build All
and Project/Build
Project
menu items check for
syntax errors but don't generate executable code
- My experience with Eclipse is limited. If you can provide me with more
information on using Gnatbench, I'd appreciate it.
- Dr. Uppuluri put together these instructions for installing
gnatbench. Some changes may be needed for your version of Eclipse, but
the instructions should still be useful.