Installing ghdl from source on Ubuntu 16.04

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


Installing QEMU on Ubuntu 16.04

These are my experiences from installing QEMU from source, on Ubuntu 16.04.1.

Starting from the QEMU main page, I navigated to the download page. I downloaded using the command


I unpacked the file using

tar xvjf qemu-2.7.0-rc2.tar.bz2

Changing directory as

cd qemu-2.7.0-rc2

I could then do the configuration, using the command

./configure --target-list=i386-softmmu,arm-softmmu,x86_64-softmmu --disable-vnc --enable-sdl

This, however, resulted in an error, as

qemu-2.7.0-rc2$ ./configure --target-list=i386-softmmu,arm-softmmu,x86_64-softmmu --disable-vnc --enable-sdl

ERROR: zlib check failed
Make sure to have the zlib libs and headers installed.

The zlib libs and headers were then installed, using the command

sudo apt-get install zlib1g-dev

Trying the configure command again resulted in

qemu-2.7.0-rc2$ ./configure --target-list=i386-softmmu,arm-softmmu,x86_64-softmmu --disable-vnc --enable-sdl

ERROR: User requested feature sdl
configure was not able to find it.
Install SDL devel

which was solved using the installation command

sudo apt-get install libsdl2-dev

Now the configure command went through!

But make failed!

qemu-2.7.0-rc2$ make
GEN i386-softmmu/config-devices.mak.tmp
GEN i386-softmmu/config-devices.mak
GEN arm-softmmu/config-devices.mak.tmp
GEN arm-softmmu/config-devices.mak
GEN x86_64-softmmu/config-devices.mak.tmp
GEN x86_64-softmmu/config-devices.mak
GEN config-all-devices.mak
GEN config-host.h
(cd /home/ola/qemu/qemu-2.7.0-rc2/pixman; autoreconf -v --install)
/bin/sh: 1: autoreconf: not found
Makefile:213: recipe for target '/home/ola/qemu/qemu-2.7.0-rc2/pixman/configure' failed
make: *** [/home/ola/qemu/qemu-2.7.0-rc2/pixman/configure] Error 127

So it was time for

sudo apt-get install autoconf

Here I remembered having used apt instead of apt-get, when I did an installation of another program, so I consulted this page about apt vs apt-get.

I tried

sudo apt install autoconf

which worked fine.

Running make now gave another error, as

qemu-2.7.0-rc2$ make
(cd /home/ola/qemu/qemu-2.7.0-rc2/pixman; autoreconf -v --install)
autoreconf: Entering directory `.'
autoreconf: not using Gettext
autoreconf: running: aclocal
autoreconf: tracing
autoreconf: not using Libtool
autoreconf: running: /usr/bin/autoconf error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
Makefile:213: recipe for target '/home/ola/qemu/qemu-2.7.0-rc2/pixman/configure' failed
make: *** [/home/ola/qemu/qemu-2.7.0-rc2/pixman/configure] Error 1
make: *** Deleting file '/home/ola/qemu/qemu-2.7.0-rc2/pixman/configure'

which led me to install libtool, as

sudo apt install libtool

And now make started to build things – and it seemed to have succeeded!

I then did

sudo make install

which, since the configure command included x86 as well as ARM as targets, we should be able to run Linux for x86 and for ARM on our newly installed QEMU.

Doing some search, and looking at this page about booting a raw disk image in QEMU, led me to commands for obtaining and unpacking a Linux image for x86, as

cd ..
mkdir i386
cd i386/
bunzip2 linux-0.2.img.bz2

QEMU could then be started, with this Linux image as the chosen software, as

qemu-system-i386 -drive format=raw,file=linux-0.2.img

For ARM, I did

cd ..
mkdir arm
cd arm
tar zxvf arm-test-0.2.tar.gz

I could then run QEMU, with the downloaded ARM Linux as software, by doing

cd arm-test/
qemu-system-arm -machine integratorcp -kernel zImage.integrator -initrd arm_root.img -nographic -append "console=ttyAMA0"

For this example, I used Ctrl-A followed by x, to exit the QEMU simulation.