Skip to content

Instantly share code, notes, and snippets.

@1papaya
Last active June 13, 2024 18:04
Show Gist options
  • Save 1papaya/568c4580b1909071696c1cb119101823 to your computer and use it in GitHub Desktop.
Save 1papaya/568c4580b1909071696c1cb119101823 to your computer and use it in GitHub Desktop.
Install GDAL 2.3 with ECW support on Ubuntu 18.04
#!/bin/bash
##
## Tested on: Ubuntu 18.04 & ECW 5.4 & GDAL 2.3.1
##
## Download the ERDAS ECW JP2 SDK v5.4 Linux
## https://download.hexagongeospatial.com/downloads/ecw/erdas-ecw-jp2-sdk-v5-4-linux
## Download GDAL v2.3 Source (ex. 2.3.1)
## http://trac.osgeo.org/gdal/wiki/DownloadSource
## First remove gdal if it's already installed
sudo apt remove gdal-bin gdal-data libgdal20
sudo apt autoremove
sudo apt install libpng-dev
## Unzip ECW libraries and install.
## At the menu, select 1 for "Desktop Read-Only Redistributable"
unzip erdas-ecw-sdk-5.4.0-linux.zip
chmod +x ERDAS_ECWJP2_SDK-5.4.0.bin
./ERDAS_ECWJP2_SDK-5.4.0.bin
## Copy new libraries to system folder
## Rename the newabi library as x64 and move necessary libraries to /usr/local/lib
sudo cp -r ~/hexagon/ERDAS-ECW_JPEG_2000_SDK-5.4.0/Desktop_Read-Only /usr/local/hexagon
sudo rm -r /usr/local/hexagon/lib/x64
sudo mv /usr/local/hexagon/lib/newabi/x64 /usr/local/hexagon/lib/x64
sudo cp /usr/local/hexagon/lib/x64/release/libNCSEcw* /usr/local/lib
sudo ldconfig /usr/local/hexagon
## Build GDAL with ECW support
unzip gdal-2.3.1.zip
cd gdal-2.3.1
./configure --with-ecw=/usr/local/hexagon
make clean
make
sudo make install
## Check if it works
gdalinfo --formats | grep ECW
## Remove installation files
sudo rm -rf ~/hexagon/
echo "SKO BUFFS!"
@cdiaz
Copy link

cdiaz commented Nov 23, 2018

ibpng warning: Application was compiled with png.h from libpng-1.6.34
libpng warning: Application is running with png.c from libpng-1.2.56
libpng error: Incompatible libpng version in application and library

@lucapost
Copy link

lucapost commented Dec 4, 2018

hi, how can I enable ecw on linux qgis?

@Primus-zhao
Copy link

Don't know why got following problem:
/libgdal.so: undefined reference to `kealib::KEAImageIO::setImageBandDescription(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)'
Is it because of missing kealib?

@eduardojsilvajr
Copy link

eduardojsilvajr commented Feb 6, 2019

hey, thanks for the help this also functioned in Kubunto 16.04 with qgis 2.18 ltr.

u also should change line 26 to sudo rm - r and u need to restart the machine to complete the process

@Andre-J
Copy link

Andre-J commented Feb 25, 2019

Lines 20 and 21 still refer to SDK v 5.3.0 and should be changed to v 5.4.0 to work properly.

For use in QGIS, take exactly the same GDAL version as QGIS is build against. https://trac.osgeo.org/gdal/wiki/ECW suggests to use GDAL 2.2.4 or newer, so I got lucky with the QGIS ubuntugis build and GDAL 2.3.2: https://gis.stackexchange.com/questions/313294/cant-install-support-for-ecw-in-qgis-3-6-3-4-on-ubuntu-18-04

@Andre-J
Copy link

Andre-J commented Feb 28, 2019

It seems to be necessary that you have to install the libpng-dev package before the self-compiling. Otherwise QGIS won't work.

@1papaya
Copy link
Author

1papaya commented Mar 8, 2019

Hi @eduardojsilvajr @Andre-J thanks for the comments, I've updated the script based upon your feedback.

@ayacoub1
Copy link

ayacoub1 commented May 4, 2019

I am new in Ubuntu and I have tried the instructions, what I need to make this build working with GeoServer and make ECW working too

@toren77
Copy link

toren77 commented Oct 16, 2019

Ubuntu 18.04
At the end of script must execute: sudo ldconfig
otherwise there is an error:

gdalinfo: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory

@IAutil
Copy link

IAutil commented Jan 2, 2020

@1papaya @eduardojsilvajr Do you know how to compile to add GML GDAL support(Ubuntu 18.04)?

@eduardojsilvajr
Copy link

@IAutil sorry, have never done this.

Copy link

ghost commented Mar 6, 2020

This script removed QGIS 3.10 from Ubuntu 18.01 and I cannot reinstall QGIS.

@addean
Copy link

addean commented Mar 31, 2020

@ayacoub1

I am new in Ubuntu and I have tried the instructions, what I need to make this build working with GeoServer and make ECW working too

are you able to make it work with geoserver? i stuck for 2 weeks

@Snixells
Copy link

Awesome! Thank you so much.

@inaferando
Copy link

Thank you! It worked for me on Ubuntu 20 as well while official GDAL manual does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment