Unable to install ECW support on lubuntu 14.04

By now, ubuntugis-unstable has added trusty packages for QGIS 2.2 and GDAL 1.11. Unfortunately, libgdal-ecw-src is still missing, and the available versions for raring and precise are intended for GDAL 1.10.

However, I got it working (with some help from the qgis user mailing list):

  1. Add ubuntugis-unstable for trusty to the sources list, or Ubuntu Software center
  2. Install QGIS 2.2, GDAL 1.11 and libgdal-dev
  3. Make sure QGIS is working
  4. Download the ERDAS ECW SDK 5.1 for Linux from http://download.intergraph.com/
  5. Open a terminal window and enter
chmod +x ECWJP2SDKSetup_5.1.1.bin
./ECWJP2SDKSetup_5.1.1.bin #Select desktop-read-only and accept the license)
sudo cp -r ERDAS-ECW_JPEG_2000_SDK-5.1.1 /usr/local/
sudo ln -s /usr/local/ERDAS-ECW_JPEG_2000_SDK-5.1.1/Desktop_Read-Only/lib/x64/release/libNCSEcw.so /usr/local/lib/libNCSEcw.so
sudo ldconfig

To avoid version conflicts, we do not install libgdal-ecw-src with apt-get, but fetch it manually and extract it:

wget https://launchpad.net/~ubuntugis/+archive/ubuntugis-unstable/+files/libgdal-ecw-src_1.10.0-1~precise4_all.deb
ar vx libgdal-ecw-src_1.10.0-1~precise4_all.deb
tar -xzf data.tar.gz
sudo cp usr/src/libgdal-ecw-1.10.0.tar.gz /usr/src/
sudo cp    usr/bin/gdal-ecw-build /usr/bin/
sudo gdal-ecw-build /usr/local/ERDAS-ECW_JPEG_2000_SDK-5.1.1/Desktop_Read-Only 

GDAL from ubuntugis is 1.11, but the script stores the plugin into /usr/lib/gdalplugins/1.10, hence it is not found by gdalinfo.

So I created a subfolder 1.11 and copied the .so file into it:

 sudo mkdir /usr/lib/gdalplugins/1.11
 cd /usr/lib/gdalplugins/1.10
 cp gdal_ECW_JP2ECW.so /usr/lib/gdalplugins/1.11 

Now you can run:

 gdalinfo --formats | grep -i ECW 
 ECW (rw+): ERDAS Compressed Wavelets (SDK 5.1)   
 JP2ECW (rw+v): ERDAS JPEG2000 (SDK 5.1)

The SDK folder has a testdata subfolder with some samples, which should work with QGIS (also on Windows and Ubuntu 12.04).


UPDATE 09-2015

It seems that my workaround does not work with newer versions of ubuntu. There is no gdal package yet available at ubuntugis for vivid (15.04). Utopic (14.10) might be the latest to work, but I have not tested it.


UPDATE 02-2019

For Ubuntu 16.04 and newer, you might follow How to get ECW support on QGIS 2.16 - Ubuntu 16.04? and Can't install support for ECW in QGIS 3.6 / 3.4 on Ubuntu 18.04

Tags:

Ubuntu

Qgis

Ecw