How do you install GNAT (GNU Ada) on a Windows computer?

10,940

Solution 1

If you later decide to install MinGW Ada, you can update your existing installation using the mingw-get command, shown below, e.g. mingw-get install ada. More details may be found here.

An alternative compiler has its uses, as suggested in this related answer.

$ mingw-get --help
Manage MinGW and MSYS installations (command line user interface).

Usage:
  mingw-get [OPTIONS] ACTION [package-spec ...]

  mingw-get update
  mingw-get [OPTIONS] {install | upgrade | remove} package-spec ...
  mingw-get [OPTIONS] {show | list} [package-spec ...]

Options:
  --help, -h      Show this help text
  --version, -V   Show version and licence information

Actions:
  update          Update local copy of repository catalogues
  list, show      List and show details of available packages
  install         Install new packages
  upgrade         Upgrade previously installed packages
  remove          Remove previously installed packages

Package Specifications:
  [subsystem-]name[-component]:
  msys-bash-doc   The 'doc' component of the bash package for MSYS
  mingw32-gdb     All components of the gdb package for MinGW

Use 'mingw-get list' to identify possible package names
and the components associated with each.

Addendum: On Windows XP, I piped mingw-get list through grep to pare the list.

$ mingw-get list | grep -i ada
...
Package: mingw32-gcc-v3-ada                           Subsystem: mingw32
The GNU Ada Compiler
This package provides the MinGW implementation of the GNU  Ada  language
written in the Ada language.
...
$ gnatmake --version
GNATMAKE 4.5.2
Copyright (C) 1995-2010, Free Software Foundation, Inc.
...

Solution 2

I uploaded the 64bit GNU ada on SF.NET within the Mingw-w64 project.

Solution 3

Go to AdaCore’s Libre site, download the installer and run it!

That said, I think you’re going to have a problem with your scheme of compiling your source files individually; Ada code has to support elaboration, which isn’t something you’d want to manage by hand. I haven’t checked it myself (I don’t program on Windows if I can help it), but here is some information on using GNAT with Windows; worth a look.

Solution 4

Stuff like Ada Web Server requires Ada developer to have a unix-like environment even on Windows so I always install MSYS together with GNAT GPL. There are several guides on how to use MSYS together with MinGW. The only problem is that recent MSYS automated installer is by default configured to use non-AdaCore MinGW which is not what we want.

The latest normal (non-automated) installer of MSYS is here:

http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download

After installation you will be asked for MinGW location. Write c:/GNAT/2012 or whatever you use for GNAT (without bin).

On Windows Seven this script failed for unknown reason, but connecting MSYS and MinGW is as simple as writing

c:/GNAT/2012 /mingw

into C:\msys\1.0\etc\fstab

Share:
10,940
johnki
Author by

johnki

Updated on July 26, 2022

Comments

  • johnki
    johnki almost 2 years

    Alright, I'm looking into doing a multi-language project. I'm looking at part of that being in Ada. I'm already aware of the AdaCore packages, but I would need to link each file separately, meaning it would probably be easiest to go straight through GCC.

    The only problem is that GNAT is apparently mostly written in Ada and I can't seem to find a guide on how to install it anywhere.

    MinGW took care of a few of the other languages for me, but apparently GNAT wasn't included in that.

    Thanks in advance!

  • johnki
    johnki over 12 years
    I think I may have worded it poorly. From what I've read, in most cases, the only ways to combine languages are to either (a) find a compiler (like Visual Studio/.NET) that support mixing languages, or to compile separately and link the object files. With that knowledge in mind, I came to the conclusion that I will probably have less headaches learning to use GCC off the command line.
  • johnki
    johnki over 12 years
    Ah, so that's how you get the MinGW Ada compiler. I had used the mingw-get-inst installer when I'd installed it and it seemed to have left it out, along with the Java compiler.
  • trashgod
    trashgod over 12 years
    IIRC, the GUI installer offers it as an option.
  • trashgod
    trashgod over 12 years
    I've gown accustomed to gnatmake, but I recall using gcc -c, gnatbind and gnatlink separately.
  • johnki
    johnki over 12 years
    I didn't have it as an option. I only had C, C++, Obj-C, Fortran, MSYS and the Developer Toolkit, running mingw-get-inst-20111118. Also, attempting it off of the command line, ada came up as an unknown package, and the list is so massive, the part I'd need to see gets cut off before I can read it.
  • johnki
    johnki over 12 years
    What I ended up doing was downloading an older version of the GUI installer, which allowed me to download the Ada compiler. However, I might have to reinstall the new stuff, because it appears to have overwritten the newer versions of other important stuff (GCC was required to install anything, reinstalling libs, etc). EDIT: I re-used the newer get-inst installer, and it seems to have re-upgraded everything just fine. :)
  • trashgod
    trashgod over 12 years
    I'm nonplussed; more above. Edit: I had used mingw-get-inst-20110316.
  • johnki
    johnki over 12 years
    Okay, I'll see if there's a more recent distro that comes with that I can upgrade to. The mingw32-gcc-v3-ada package seems older, and installs GCC v3.4.5 with it. I'm also concerned I may have botched my install after all, as my GCC is reading 4/17/2010 for its last modified date, which is the same as the ada install, as opposed to closer to August or September of this year. Then again, it may just be that I paid no attention when I installed it the first time. However, I've got 3 mingw-gcc executables...mingw-gcc, mingw-gcc-4.5.0, and mingw-gcc-4.6.1.
  • Simon Wright
    Simon Wright over 12 years
    As I remember it, gnatbind creates the elaboration code (now b~main.ad[bs] - back in the day it was in C, not Ada, and there may still be an option for that) containing a list of all the object code modules required for the link embedded as a comment; gnatlink processes this and runs the actual link, and we had to roll our own for that part of it.
  • trashgod
    trashgod over 12 years
    Ah, tempus fugit! @johnki: For gnatbind, the -g option preserves the b~ files from which adainit and adafinal are exported; -n specifies a foreign main routine, in which adainit and adafinal should be called.
  • Simon Wright
    Simon Wright over 12 years
    @trashgod: It’s a gnatlink option; gnatlink --help doesn’t actually mention that -g preserves these files as well as compiling them with debug.