Build QGIS with Oracle Spatial support

Here's how to build QGIS with Oracle Spatial support.

Build QGIS with Oracle Spatial support

Here's how to build QGIS with Oracle support on Debian based systems (this means also Ubuntu).

I'm using Debian Testing which at the time of writing this article has the codename Buster.

First, you need to install the QGIS build dependencies. One way of doing that is to get the dependencies that are written in the

Sometimes, there's an updating lag for the dependencies written in the INSTALL document so I tend to use the apt-get build-dep command.

In order to do that, you need to configure the QGIS software repositories on your linux box if you haven't done it already. See

Depending on what version of QGIS you want to compile, add your corresponding repositories.

For QGIS 3 (master) on my box (Buster is not available yet in the QGIS repos, but Stretch works).
So I added to the /etc/apt/sources.list the following lines:

deb stretch main
deb-src stretch main

Don't forget to add the repository public key to your apt keyring as specified in the above link.

After you add the repositories do an sudo apt-get update to get the latest lists of packages.

Now you can install the dependencies by doing sudo apt-get build-dep qgis. For the oracle build you also need to do a sudo apt-get install qtbase5-private-dev qt5-default

Now let's install the Oracle dependencies:

mkdir -p ~/dev/oracle && cd ~/dev/oracle

In order to download the dependencies from Oracle ( you need to register an account.
After you made your account you need to download the following files in the ~/dev/oracle directory:

From what I can recall, not all of these are needed but at the time when I took the notes I wanted to do some extra stuff, you have it all.

To install the rpm files on a debian system:

sudo apt-get install alien libaio1 -y
# Create the deb files from the rpm ones:
sudo alien oracle-instantclient12.2-*
# install the deb files
sudo dpkg -i oracle-instantclient12.2-*.deb
# setup the libraries
sudo sh -c 'echo "/usr/lib/oracle/12.2/client64/lib" > /etc/'
sudo ldconfig
# check that the libraries are loaded with
sudo ldconfig -p | grep oracle

Setup the Oracle variables that many programs lool for by adding to the /etc/profile.d/ file:

export ORACLE_HOME=/usr/lib/oracle/12.2/client64

Fix SDK (.h files) finding if there is no include directory under ORACLE_HOME, and it is located over in /usr/include/oracle/, by creating a symbolic link to assist packages looking for these header files:

sudo ln -s /usr/include/oracle/12.2/client64 /usr/lib/oracle/12.2/client64/include
sudo mount --bind /usr/include/oracle/12.2/client64 /usr/lib/oracle/12.2/client64/include

See also Instant Client for more info.

mkdir -p ~/dev/cpp && cd ~/dev/cpp
git clone qgis
mkdir qgis/build-master && cd qgis/build-master

If you want to look at the compile options graphically you should first do a sudo apt-get install cmake-curses-gui.
Now that the ccmake command is installed you can play around with it by doing a ccmake -G Ninja .. that should first output something like this:


Press [enter] to edit option Press [d] to delete an entry       

CMake Version 3.9.5
Press [c] to configure
Press [h] for help           Press [q] to quit without generating
Press [t] to toggle advanced mode (Currently Off)

By pressing c at least one time you can get an automatic configuration. Most of the options are automatically configured but some need to be specified.

Some options that are important (for me at least)
Config OptionConfigured option

Keep in mind that some of the options appear after configuring others and pressing c again. If it looks ok to you, and you have the press g option, press it and then start the build.

I personally don't use ccmake anymore since I'm using the cmake arguments to configure my build:

cmake \
-G Ninja \
-D OCI_INCLUDE_DIR=/usr/lib/oracle/12.2/client64/include \
-D OCI_LIBRARY=/usr/lib/oracle/12.2/client64/lib/ \

If you want to install it instead of running QGIS from the output directory you need to do:

sudo ninja install
sudo chown -R $USER:$USER $HOME/qgis-master

You need root privileges for the install if you have built WITH_CUSTOM_WIDGETS, otherwise, the installer won't have installing rights in the QT folders. The above command restores the rights in the $HOME folder to its user.

In order to run QGIS from the install dir, we create the $HOME/qgis-master/bin/ file with the following content:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/qgis-master/lib/:${HOME}/dev/cpp/oracle-client/instantclient_12_1


Rnning sh $HOME/qgis-master/bin/ should start QGIS with ORACLE support.W

Share Tweet Send
You've successfully subscribed to
Great! Next, complete checkout for full access to
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.