Installing ghdl from source on Ubuntu 16.04

NOTE – this page needs update (see comment from Patrik Lehmann below)

I wanted to reinstall ghdl on my new Ubuntu 16.04. My first idea was to use the method I used for the previous Ubuntu version, where I downloaded a ghdl package from this page with Debian packages.

But when I looked at the page now, I did not find any package that I could get to work on Ubuntu 16.04.

I decided to try an installation from source.

I found out that the source code could be downloaded from this ghdl-updates sourceforge page.

From the information about branches, I could see the version numbers for stable versions. I chose to download the 0.33 version.

The source code download was done using git clone, as

git clone git:// ghdl-updates-ghdl-updates.git

and the 0.33 branch was checked out as

cd ghdl-updates-ghdl-updates.git
git branch
git checkout ghdl-0.33

I looked in the README file and learned that it was possible to build ghdl with gcc as backend. I decided to try this alternative. Another alternative was called mcode, but it was only available for 32-bit Ubuntu, and a third alternative was to use llvm.

The first step was to obtain an Ada compiler.

I installed gnat by doing

sudo apt install gnat

From the README file I then learned that I should download the gcc 4.9 source. I did this by doing

tar xvjf gcc-4.9.4.tar.bz2

I then configured gcc, as instructed in the ghdl source code README file, via the ghdl source configure script, using the path to my downloaded gcc source as argument, by doing

cd ghdl-updates-ghdl-updates.git/
./configure --with-gcc=/home/ola/ghdl/gcc/gcc-4.9.4/
make copy-sources
cd ..

It was now required to download and build some auxiliary packages. I did this, for the package gmp, by doing

tar xvjf gmp-4.3.2.tar.bz2
mkdir gmp-4.3.2/gmp-objs/
cd gmp-4.3.2/gmp-objs/
../configure --prefix=/usr/local --disable-shared
sudo make install
cd ../..

followed by the package mpfr, as

tar xvjf mpfr-2.4.2.tar.bz2
mkdir mpfr-2.4.2/mpfr-objs/
cd mpfr-2.4.2/mpfr-objs/
../configure --prefix=/usr/local --disable-shared --with-gmp=/usr/local
sudo make install
cd ../..

and finally, the third package mpc, as

tar xvzf mpc-0.8.1.tar.gz
mkdir mpc-0.8.1/mpc-objs/
cd mpc-0.8.1/mpc-objs/
../configure --prefix=/usr/local --disable-shared --with-gmp=/usr/local
sudo make install
cd ../..

It was now time to build the actual ghdl. Since we had decided to use gcc as backend, we accomplish the task of building ghdl by building gcc. So we go back to our directory where we unpacked the gcc sources.

In that directory, we do configuration as

cd gcc-4.9.4
mkdir gcc-objs
cd gcc-objs/
../configure --prefix=/opt/ghdl-updates --enable-languages=c,vhdl --disable-bootstrap --with-gmp=/usr/local --disable-lto --disable-multilib

In the above configuration step, we have selected the prefix as /opt/ghdl-updates. The reason for this is to avoid a collision with an already existing gcc compiler (which we already have on our system – and which we need for the build of ghdl).

For the actual build step, we need to do make. Here, I ran into a problem since the program gnat1 was assumed to be used (instead of gnat). The error was seen when doing a plain


and it showed up, after a while, as

gnatbind -Lgrt_ -o run-bind.adb -n ghdl_main.ali
gcc -c -O2 -g -gnatec../../../gcc/vhdl/grt/grt.adc -gnat05 -o run-bind.o run-bind.adb
gcc: error trying to exec 'gnat1': execvp: No such file or directory
Makefile:586: recipe for target 'run-bind.o' failed

I found this searchcode page, where the problem, and a solution, were described.

Using this newfound piece of information, I located gnat1 by doing

$ find /usr -name gnat1

I then used this directory as a part of the PATH when doing make, as

PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9:$PATH make

This resulted in a successful build.

Assuming that the PATH used for make was needed also when doing make install, I started a root shell as

sudo -i

and in that shell, after having done cd to the gcc-objs directory, I did

PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9:$PATH make install MAKEINFO=true

This completed the installation of ghdl!

I could use ghdl, on the first example from the book Into Computers, after having set the PATH as

export PATH=/opt/ghdl-updates/bin/:$PATH

as described in the book, by doing

$ ghdl -a hello.vhdl
$ ghdl -e hello_world
$ ghdl -r hello_world
Hello, world


About Ola
Writer of fiction and non-fiction, published the suspense novel Prevention - creating Books with Views - with books on programming and embedded systems -

19 Responses to Installing ghdl from source on Ubuntu 16.04

  1. Alex says:

    Woo hoo! Thanks for your effort and for posting this!

  2. Erick Ricardo Lopez Gomez says:

    hey thanks a lot for your contribution.. do you think there’s a way to avoid write the hole “PATH…….” command before using ghdl???? chreeers

  3. Ola says:

    I needed the PATH command since I chose a non-standard location for my installation. I guess if you omit the –prefix=/opt/ghdl-updates in the ./configure command for ghdl, or perhaps use –prefix=/usr/local, then you would not have to do the PATH command. Another alternative could be to put the PATH command in a file, e.g. named, with contents like

    export PATH=/opt/ghdl-updates/bin/:$PATH

    and then source the file as

    before you start to use ghdl.

  4. tom says:

    Thx for help. F*cking stupid. I don’t know why they didn’t include ghdl in 16.04… You saved the day

  5. Eric Hazen says:

    Thanks very much for posting this! You saved me a lot of trouble. Your recipe worked 100% the first time.

  6. Wonderful, Thanks for your time and dedication, this post is very useful.

  7. Wytos says:

    I want share my experience: I had different trouble but in the end I made it working, and I’m really happy, so really thank you Ola!
    My first problem was not installed ‘m4’ which caused gmp configuring going wrong, sol: installing m4 with “sudo apt-get install m4”.
    Then the other compiling were good except the last one, so I launched “./configure”, “make”, and “sudo make install” directly from source ghdl directory (ghdl-updates-git), and it worked, I tested it with hello.vhdl.
    You made my day, again thank you!

    • Ola says:

      Thanks for your feedback! The reason I did not see the m4 problem was most likely that I had m4 already installed (perhaps from an earlier install of some program other than ghdl)

  8. Ajinkya says:

    ./configure –with-gcc=/home/ola/ghdl/gcc/gcc-4.9.4/

    above mentioned line gives me following error-
    Build machine is: x86_64-linux-gnu
    cannot find gcc/BASE-VER in /path/to/gcc/source/dir

    Please help me to rectify the problem.

    • Ola says:

      The path /home/ola/ghdl/gcc/gcc-4.9.4/ was where I put my downloaded gcc. See the wget command just above the line where you had a problem.

      Perhaps you put your downloaded gcc somewhere else?

      Best regards,


  9. BAH Maimouna says:

    It’s so cool but unfortunately it didn’t solve my problem…still don’t have ghdl in my computer

  10. Patrick Lehmann says:

    Please update the presented installation instructions, because they are outdated. E.g. GHDL is not hosted at SourceForge anymore. See the official GHDL documentation for updated installation instructions.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: