3

I've recently started working on a project that requires my complier to be above GNAT 4.8.5 - When I go to: Help > About

enter image description here

You can see that the version I'm using is 4.8.5

enter image description here

Also, when I run the gnatls -v command, I can see this...

[parallels@localhost ~]$ gnatls -v

GNATLS 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 1997-2013, Free Software Foundation, Inc.

Source Search Path:
   <Current_Directory>
   /usr/lib/gcc/x86_64-redhat-linux/4.8.5/adainclude/


Object Search Path:
   <Current_Directory>
   /usr/lib/gcc/x86_64-redhat-linux/4.8.5/adalib/


Project Search Path:
   <Current_Directory>
   /usr/x86_64-redhat-linux/lib/gnat
   /usr/share/gpr
   /usr/lib/gnat

[parallels@localhost ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-multilib --enable-languages=c,c++,ada
Thread model: posix
gcc version 7.3.0 (GCC) 
[parallels@localhost ~]$ 

Please could someone be able to tell me how to update my GNAT compiler? Also, I'm using the Centos 7 Operating System.

Thank you,

Lloyd

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Lloyd Thomas
  • 345
  • 2
  • 12
  • 1
    ? Have you got a manually installed "gcc 7.3.0" in /usr/local/ ? Please edit your question https://stackoverflow.com/posts/61632284/edit ... to show available gcc -7.3.0 executable's. .... Images https://unix.meta.stackexchange.com/questions/4086/psa-please-dont-post-images-of-text – Knud Larsen May 06 '20 at 14:12

2 Answers2

6

You don't need to install a compiler, you already have 3 (at least):

  • gcc 4.8.5 (the system compiler) in /usr/bin
  • gcc 7.3.0 (that you just built) in /usr/local/bin
  • gcc 8.3.1 (from GNAT CE 2019) in /home/parallels/opt/GNAT/2019/bin

Your PATH determines which GCC you pick up when you say just gcc, and which GNATLS you pick up when you say just gnatls, .. etc.

According to a previous post, your PATH is:

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/var/lib/snapd/snap/bin:/home/parallels/.local/bin:/home/parallels/bin/home/parallels/opt/GNAT/2019/bin/home/parallels/opt/GNAT/2019/bin

so when you say just gcc the system looks at the first entry in the PATH (which is colon-separated) and .. there it is! so it executes that.

If you'd built your 7.3.0 GCC with Ada support, it would have found gnatls in the same place. I have a very strong suspicion that you didn't, so when you say just gnatls the system looks in /usr/local/bin - no luck - then in /usr/local/sbin - no luck - then in /usr/bin - whoopee! but that's the 4.8.5 GCC that you don't want.

Looking again at your PATH, the last part is mangled - you've added /home/parallels/bin and /home/parallels/opt/GNAT/2019/bin (twice) without including the colon separators, resulting in a nonexistent path. (/home/parallels/bin may well have been added by the system - I assume that /home/parallels is your home directory).

What you need to do is to make sure that you pick up the compiler that came with GNAT CE 2019 by putting its location first in your PATH. One way of doing this is by editing your shell startup files.

I don't know how CENTOS sets accounts up, and I don't know what your shell is. Assuming it's bash (type ps -p $$, should come back with bash or perhaps -bash; anything else, I can't help), you need to edit one of the shell startup files - I'm a little unclear about this, but I think it'll be ~/.bashrc (~ is shorthand for your home directory); see here for the gory details. Find the last mention of PATH and immediately after that line insert

export PATH=/home/parallels/opt/GNAT/2019/bin:$PATH

Open a new terminal window and say e.g. gnatls -v - you should pick up the GNAT CE 2019 one.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • 2
    Just wanted to comment here that this doesn't always work in every linux environment by itself. We had a redhat environment where setting the path alone did not fully work. Additionally we had to adjust the toolchain settings (usually under the build menu). The dialog there had two paths to also modify compiler path and tools path, in addition to a checkbox to allow for multiple toolchains that needed to be checked to set those. I don't know why our environment required that, but might be something to keep in your back pocket. – Jere May 06 '20 at 19:06
  • Cheers @Jere, thank you for the heads up. This is something I will keep in mind. – Lloyd Thomas May 07 '20 at 08:55
  • Hi @Simon Wright, thank you very much for your detailed awser. This has helped me resolve the issue, I have changed the PATH and updated the complier. When I go to: Help > About within CE 2019 I now see this GPS 19.1 (20190106) hosted on x86_64-pc-linux-gnu GNAT Community 2019 (20190517-83) the GNAT Programming Studio (c) 2001-2019 AdaCore Many thanks – Lloyd Thomas May 08 '20 at 07:31
0

Only way I know of updating GNAT GPS CE from AdaCore is downloading the new one, installing it and then deleting the old one.

Another thing is to upgrade the gnat-gps that some systems had in ther repositories