Using GDAL from within QGIS: trouble shooting

Some notes to self about steps I had to take to make GDAL work from within QGIS. Both where compiled from source and run without problems. However, there are still a few issues with running gdal from the QGIS processing toolbox. This may have to do with the fact that I installed both in a non-default location (in the /usr/local/ folder), but in any case, the steps below solved the problem for me.

Create a softlink of the gdal executables in /usr/bin

cd /usr/bin
sudo mkdir gdal
sudo ln -s /usr/local/gdal/bin/    /usr/bin/gdal/

Create config file in with path to the gdal libraries

sudo sh -c "echo /usr/local/gdal/lib > /etc/"
 sudo ldconfig

Define the gdal path in the .bashrc file
In the file ~/.bashrc file, add the line:

export PATH=$PATH:/usr/local/gdal/bin

The above was enough to make the gdal functions on the raster menu run without problems. Yet, running gdal from the processing toolbox gave me the error:

/bin/sh: 1: gdalinfo: not found.

Define the gdal path in the .configure file

As it turned out, the gdal functions in the processing toolbox actually work if I start QGIS from the command line, but not, as I normally do, if started with Alt+F2 (run command). To make it work both from the command line and when starting QGIS via Alt+F2, you should define the path in the file ~./configure.

export PATH=$PATH:/usr/local/gdal/bin

The steps above work for me, but note that thinks may differ depending on the Linux flavour and your configuration settings when compiling QGIS and GDAL.


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s