How to Install SWI-Prolog on Ubuntu 16.10 Yakkety Yak

SWI-Prolog Logo

I know that this post will probably be of interest to about a dozen people worldwide, and even those few may be disappointed by it. Since the official SWI-Prolog packages aren’t often kept up to date and because compiling and installing SWI-Prolog from source should be both quick and straightforward, that is the recommended way to do it on Linux and other *nix systems.

If you are looking for tips, tricks or assistance with an installation problem, you likely won’t find it here. The instructions provided on the SWI-Prolog site for building and installing SWI-Prolog from source code “just worked” for me. Nevertheless, I want to document what I did, and if you are looking for the Cliff Notes version, then by all means, read on.

Before compiling SWI-Prolog and its packages on Ubuntu, there are a raft of dependencies that must be installed first. You can read more about required software at:, but the short of it is that the following apt-get command will get the job done:

sudo apt-get install \
        build-essential autoconf curl chrpath pkg-config \
        ncurses-dev libreadline-dev libedit-dev \
        libunwind-dev \
        libgmp-dev \
        libssl-dev \
        unixodbc-dev \
        zlib1g-dev libarchive-dev \
        libossp-uuid-dev \
        libxext-dev libice-dev libjpeg-dev libxinerama-dev libxft-dev \
        libxpm-dev libxt-dev \
        libdb-dev \
        openjdk-8-jdk junit

Once you’ve got the prerequisites installed, grab the source code here:

Open a terminal and change to the directory to which you downloaded the source code tarball and unzip and untar it:

tar xzvf swipl-<version>.tar.gz

Change to the newly created source directory:

cd xzvf swipl-<version>

SWI-Prolog offers two ways to compile and install the source code: a single-step easy way and a multiple-step hard way. The hard way is the way most of are used to doing when compiling and installing source on Linux: ./configure, make, [sudo] make install. Simple enough for just the main executable, but then you need to change to each package directory and do the same thing for every one of them. Fortunately SWI-Prolog comes with a shortcut script that automates the entire process for you. This script is build.tmpl.

First copy build.tmpl to build:

cp -p build.tmpl build

If you are happy to use the default build and install options, you can skip to the final step of the process right now.

By default SWI-Prolog is installed for just your user in your home directory at: $HOME/lib/swipl-<version> and symlinks for the executable are created in $HOME/bin. However, I wanted to do a global install in /usr/local instead so I needed to edit build. If you would like to the same, follow along.

Open build in your text editor of choice and look for these two lines:


and change them to:


The build script will not only install to the /usr/local directory, but it will also know that it needs to use sudo to install to the protected system directory.

build also allows you to set other compiler options, but on Ubuntu at least you should not need to do so.

Time to compile and install SWI-Prolog which is done by running the build script:


The output of the ./configure and make commands should stream without error across the screen. If you’ve chosen to install the software to a directory that requires sudo, you’ll be prompted for your password when the process gets that far. Otherwise it will run to completion without requiring user input.

If build finishes running without error, you have been successful. To verify, launch SWI-Prolog:


As I stated in the beginning, this compilation and installation worked for me with no tweaking or troubleshooting. If you have problems, or better yet, if you had problems and solved them, please share them in the comments below. Thanks!

1 comment

    • Hande Gulec on May 23, 2017 at 2:01 pm
    • Reply

    thank you so much 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.