Uninstall ‘libgdal-dev’ if installed:
sudo apt-get remove libgdal-dev
Download and extract the gdal source code:
wget http://download.osgeo.org/gdal/2.2.4/gdal-2.2.4.tar.gz
tar -xvzf gdal-2.2.4.tar.gz
cd gdal-2.2.4
Configure and compile:
./configure --prefix=/usr
make
Build and install the Debian package:
sudo apt-get install checkinstall
sudo checkinstall
This will build a debian package that can then be normally installed and removed using the package manager.