Ada Programming $WikiTagline

The following description shows how to compile you very own GNAT environment. It make the following assumptions:

  1. You use a Linux environment with the following packages.
  2. * A gcc with an old Ada compiler
  3. * The usual automake packages.
  4. You want the newest GNAT 3.4
  5. You do your compiles in /work – 2,0G of space are needed (344M Sources, 1.7G per target).
  6. You do your install in /opt – 579M of space are needed.
  7. You do have an Internet connection up and running.

If you want it any other way you need to use your brain to change the command appropriately.

Important: All questions and suggestions regarding this document should be posted to the following forum.

The Compiler

Most Linux distributions contain an gcc 3.3.x – but the Ada compiler for that version is quite buggy – compared with its predecessors and successors. All you really should do with that compiler is to compile a newer version.

Get the Compiler

First you need the get the compiler. Please note that a complete CVS checkout downloads about 167MB. Luckily you only need to do that once and cvs uses bzip2 to compress the data on route.

 mkdir --parents /work/gnu_3.4
 cd /work/gnu_3.4
 cvs -qz4 checkout -P -r gcc-3_4-branch gcc

Now you have the newest sources in “/work/gnu_3.4/gcc”. You may cut your Internet connection now. If you rather want a release version then bleeding edge you can use for example &ldquogcc_3_4_3_release” for release 3.4.3 instead “gcc-3_4-branch

On the other hand the gcc 3.4 compiler does not only have less bugs. It also has a lot of nice new features.

Thank you ACT for providing such a wonderful compiler for free. You only need to invest in an Internet connection and some time to do the compile.


Unlike other source packages gcc is build for cross compiles. So you can't just type “configure” but you have to do so in an empty directory:

 mkdir /work/gnu_3.4/$(gcc -dumpmachine)
 cd /work/gnu_3.4/$(gcc -dumpmachine)
 /work/gnu_3.4/gcc/configure                     \
         --with-gcc                              \
         --with-gnu-ld                           \
         --with-gnu-as                           \
         --prefix=/opt/ada                       \
         --enable-libada                         \
         --enable-libgcj                         \
         --enable-java-gc=boehm                  \
         --enable-threads                        \
         --enable-interpreter                    \
         --enable-hash-synchronization           \
         --enable-shared                         \

If you need more then one version for different targets (Windows, Linux, x86_64) then just create some more empty directories.

Of course, from time to time, you want update to the newest compiler. And once the system is up and running that is easy enough:

 cd /work/gnu_3.4/gcc
 cvs -qz4 update -P -d -C
 cd /work/gnu_3.4/$(/opt/ada/bin/gcc -dumpmachine)
 make -C gcc gnatlib-shared gnattools;
 make install

Just one warning: cvs sources don't always compile. You should not install them before you made shure they do actually compile.

Problem shooting

Sometimes there are problems with the compile. Here a few common one:

Compiler options and the config.cache files

The compile fails and suggests either to do a “make distclean” or remove the “config.cache” file. Best to remove the files (more then just one):

 find . -iname "config.cache" -exec rm -vf '{}' ';'

Exception Handling

The compile fails with an error about inconsistent exception handling. You probably mixed up two different gcc version when compiling. Use “make clean” to clean up the mess and make sure that ${PATH} point so the right gcc.

Anything else

This is a Wiki - so if you have any suggestions or questions you can add them right here.

Could there be a Batch to do it all?

Yes, you may try to download my build-gcc and build.bash batch which can compile all GCC 3.4 Versions and GCC 4.0. Copy to /work/build and call without parameter for further instructions. Note: by tj_yang AT, build-gcc bash script has problem on RH9 for those screen control characters. I took them out to resolve build-gcc hang issue.

© 2005,2006 Martin Krischik, Content is available under GNU Free Documentation License.