ada works . it

Start in GNAT Studio

These instructions are for installing and starting programming using AdaCore's "GNAT Studio 2020" on a 64bit computer with a Linux Fedora 40 operating system.

There are alternatives for AdaCore's "GNAT Studio".

Computer

These instructions have been tested on 15 April 2023 on a computer that I had previously installed "GNAT Studio 2021" with a fresh operating system installation WITH updates on 16 Feb 2023. I can see no reason why they shouldn't also work for a fresh installation;

The computer has;

It is expected that the instructions here will work on a far lower specification machine.

The text editor that comes as default is Pluma and this was used.

Notation

Text written by the computer is shown in this style such as the terminal's user prompt;

[john@silver ~]$

Text you should type at the prompt is shown in this style.

Other computer code such as programs are shown in this style.

GNAT Studio Installation process

BEFORE YOU INSTALL "GNAT Studio" YOU MUST have "GNAT" installed. Follow the "GNAT Installation process" to be fount on the Start in GNAT page, if you don't have GNAT installed already, and then return here.

Download the files for "x86 GNU Linux (64 bits)", the "readme.txt", and "gnat-2020-20200818-x86_64-linux-bin" from AdaCore;

https://www.adacore.com/download/more

this is about half a Gigabyte. Make sure you select the correct file and year at the top.

It is possible they will have updated the installation file "gnat-2020-20200818-x86_64-linux-bin" and it will have been replaced by a similarly named file i.e. "gnat-2020-2020XXXX-x86_64-linux-bin" where Xs ar digits. If so then replace the references below to the original file name with the new file name when executing your commands.

Unfortunately the "readme.txt" file is not clear and also contains errors. It describes installation for Windows, Linux and Mac in a single file and omits certain crucial details that can corrupt the installation!

or the install process will work improperly. One error being;

/opt/GNAT/2020/bin/gps_exe: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

On most programmer's systems this library is already present for C/C++ work and so it's absence goes unnoticed!

Please contact AdaWorks should you find errors in our work as we will endeavour to make corrections.

It should be said that despite these errors AdaCore have, and continue to provide GNAT Studio for free to non-commercial bodies, which must be appreciated. Thank you AdaCore.

You should be aware that GNAT Studio is not free when using it for the development of commercial software products and you should talk to them about buying a licence. For this you will receive their support service.

You can however develop commercial products using GNAT without GNAT Studio. See Starting GNAT but you lose the benefit of a good tool.

Installation Process

Install missing libraries

Because we are running an older version of GNAT Studio it may require some older libraries. Now you can install the possibly missing libraries with;

[john@silver ~]$sudo dnf install ncurses-compat-libs

This will either install the missing libraries mentioned above or tell you that the libraries are already installed with a message like;

Last metadata expiration check: 3:29:56 ago on Tue 24 Nov 2020 07:08:17 CET.
Package ncurses-compat-libs-6.2-3.20200222.fc33.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

Another important library that can stop the debugger running properly is libcrypt.so.1 so to fix that;

[john@silver ~]$sudo dnf install libxcrypt-compat

As before, this will either install the missing libraries mentioned above or tell you that the libraries are already installed.

Once you have installed the missing libraries then you can install GNAT Studio.

In case your interested this is what chat gpt tells me ncurses is for.

ncurses-compat-libs is a package that provides backward compatibility for the NCURSES library, particularly for older applications that rely on previous versions of NCURSES. NCURSES (new curses) is a library used for creating text-based user interfaces (TUIs) in terminal environments, providing functionality to handle screen painting, keyboard input, and more.

The ncurses-compat-libs package includes older versions of the NCURSES libraries, ensuring that programs compiled with older versions of NCURSES can still run properly without requiring recompilation against the latest version of the library.

On Fedora, installing ncurses-compat-libs would allow legacy applications that depend on older NCURSES features or APIs to function correctly, even if the system uses a newer version of NCURSES by default.

Install GNAT Studio

Move "gnat-2020-20200818-x86_64-linux-bin" into your home directory.

Open a terminal and make sure it is executable with the command;

[john@silver ~]$chmod +x gnat-2020-20200818-x86_64-linux-bin

Then install with the command;

[john@silver ~]$sudo ./gnat-2020-20200818-x86_64-linux-bin

A dialogue window opens, accept the default options and work through to the "Finish". The GNAT Studio installation is complete.

Just one little problem

There is always something. I found that my programs compiled OK but would not link! It took me 2 days and nights to solve this "little problem" with these instruction;

[john@silver ~]$cd /opt/GNAT/2020/libexec/gcc/x86_64-pc-linux-gnu [john@silver x86_64-pc-linux-gnu]$ls 9.3.1

the command ls lists the files and directories and normally you find a directory with a name like 9.3.1 basicly 3 numbers seperated by dots change to the directory with.

[john@silver x86_64-pc-linux-gnu]$cd 9.3.1

Where the 9.3.1 is replaced with your three numbers.

This is a directory structure installed as part of GNAT Studio and in it, it provides the command ld which is the link command. We will find out about linkers later on. GNAT Studio replaces Fedora 40's version of ld with it's own one that DOESN'T work and generates nasty errors. So what do we need to do? We get rid of it by renaming it with;

[john@silver 9.3.1]$sudo mv ld ldOLD

Once this is done a call to use ld ends up using Fedora's version of the command which works. Having sorted that out, let's continue. (Two days wasted!)

Setup Your Working Folder

It is convenient to set up a working folder for all your Ada programming with the following path;

~/prog/ada

You can do it with the folloing commands;

[john@silver ~]$mkdir prog

[john@silver ~]$mkdir prog/ada

I recommend that you set up the following executable script called "ada" in your home folder. Further instructions will assume that is what you have chosen to do;

cd prog/ada
export PATH=/opt/GNAT/2020/bin:$PATH
gnatstudio

so when you login in the morning you just type;

[john@silver ~]$./ada

at the [john@silver ~]$ prompt and it starts gnat studio in the right place. DON'T FORGET the year, in this script must be, 2020 to be the correct year for the version you have installed.

You can use your text editor to create the file and save it in your home directory. Then make it executable with;

[john@silver ~]$chmod +x ada

Notes

Note that the script modifies the system PATH variable non-permanently. DO NOT modify the system path variable permanently otherwise when developing in other languages you find the IDEs looking in the folders that belong to GNAT before they look in their own folders, and then they often find the wrong things in unpredictable ways.

Styles

You may want to change the font styles. On the Edit menu click "Preferences", in the preferences window select "General" then click "Custom Styles".

in the preferences window select "Editor" then click "Fonts & Colors".

While we are on the "Peferences" we might as well increase the number of lines of the Run window where the program output appears. On the right of the "Preferences" window is a little menu icon of three horizontal bars. Click this and select "show advanced preferences". On the left top appears the word "Advanced", clicking it and scrolling almost to the bottom is a field "Console maximum length" set that to 100000 which is the maximum value it accepts.

Close the "Preferences" window.

Programming

AdaCore provide a pretty good GNAT Studio Tutorial" but it had some errors at the time I used it but hopefully those have been corrected now. I submitted this Feedback on 2020-02-26.

At some point I may take the time to write a "hello world" program or provide other material for the AdaCore GNAT Studio, but since there is a lot already out there there seems little point. I have documented this installation process because decent installation documentation was missing. I hope AdaCore will correct this oversight. Ada is a high quality language and that quality should be made apparent from the very start!

BUG: Errors not highlighted on edit window

Normally when there is an error on compiling the program, GNAT Studio gives you a link to click and it opens the editor with the error highlighted. Twice this functionality simply stopped working although it would compile and link and give files and line numbers there were no links.

After some investigation and working together with chat gpt we discovered that the problem was related to the hidden directory ".gnatstudio" in my home directory. It then turned out to be this line "<pref name="Messages-Line-Regexp-Index" > 1</pref>" in the file properties.xml which is in ".gnatstudio". Removing the line fixed the problem!

Another way to fix this is rename .gnatstudio to something like .gnatstudioBADVERSION and next time GNAT Studio starts it will generate a new clean .gnatstudio but then you will have to change the styles again. See above.