Skip to content

Instantly share code, notes, and snippets.

@aborruso
Forked from 1papaya/gdal_ecw.sh
Created March 28, 2019 12:34
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aborruso/eed6895278edd320db6631b33d10836e to your computer and use it in GitHub Desktop.
Save aborruso/eed6895278edd320db6631b33d10836e 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!"
@IlliaOvcharenko
Copy link

thank you so much!

@pteroglossusK
Copy link

Hi there,

Thanks a lot for this, I followed the steps thoroughly and everything went fine until "make clean", which got me into an infinite loop.

I'm no programmer, as you might have guessed already, just looking to work on some .ecw maps in GRASS and stay away from Windows.

Would you have some time to give me a hand?

Best,
Kevin

@aborruso
Copy link
Author

Hi @pteroglossusK my advice is to ask about compiling GDAL 2.3 with ECW support in GDAL Dev mailing list https://lists.osgeo.org/mailman/listinfo/gdal-dev

@pteroglossusK
Copy link

pteroglossusK commented Jan 27, 2021 via email

@samatict
Copy link

samatict commented May 4, 2021

Hi there,

Thanks a lot for this, I followed the steps thoroughly and everything went fine until "make clean", which got me into an infinite loop.

I'm no programmer, as you might have guessed already, just looking to work on some .ecw maps in GRASS and stay away from Windows.

Would you have some time to give me a hand?

Best,
Kevin

Thanks for all proposed scripts and solutions above. Unlucky for me, I also got stuck in the infinite loop. I had to force quit that running terminal process. After that, existing gdal running on qgis can no longer work. Then I had to follow instruction on this : https://trac.osgeo.org/gdal/wiki/BuildingOnUnix, , follow the "system install" section (it took me around 1 hour to execute that "make" line with machine getting hot), and export path (3 lines) as in the "install in non-root directory" section, in order to return back to original working gdal that still does not support ECW.

Update:
in order to return to normal working gdal with qgis, before self-compiling normal gdal source like I said above, try reinstalling first: , and then set path to default apt installation location (in my case: ). If this does not work, perhaps should proceed to self-compiling gdal again as above mentioned.

@indimedigit
Copy link

i am not able to create the make command

@aborruso
Copy link
Author

@indimedigit run this command to install make and all the packages needed to build your code:

sudo apt-get install build-essential

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