Installing libgdal-dev on Ubuntu 20.04

You don't need to add apt repository for ubuntu 20.04. Just do:

  1. sudo apt update.
  2. sudo apt install libpq-dev gdal-bin libgdal-dev

The Solution that worked for me is as follows

I was trying to install libgdal-dev and also had following error:

The following packages have unmet dependencies:
libgdal-dev : Depends: libarmadillo-dev but it is not going to be installed                           
               Depends: libdap-dev but it is not going to be installed                                 
               Depends: libgeotiff-dev (>= 1.5.0) but it is not going to be installed                  
               Depends: libhdf4-alt-dev but it is not going to be installed                            
               Depends: libhdf5-dev but it is not going to be installed                                
               Depends: libkml-dev but it is not going to be installed                                 
               Depends: liblzma-dev but it is not going to be installed                                
               Depends: default-libmysqlclient-dev but it is not going to be installed                 
               Depends: libnetcdf-dev but it is not going to be installed                              
               Depends: libpng-dev but it is not going to be installed                                 
               Depends: libspatialite-dev but it is not going to be installed                          
               Depends: libtiff-dev but it is not going to be installed

I have use aptitude to interactively resolve dependencies. You can also use the GUI ncursis version only running aptitude in terminal. It will ask to keep the current version, select n (No) and it will tell you how to resolve next. In this case it suggested downgrading packages, select 'Y' and it will install libgdal-dev successfully.

$ sudo aptitude install libgdal-dev

...
...
      Keep the following packages at their current version:                                            
1)      default-libmysqlclient-dev [Not Installed]                                                     
2)      libarmadillo-dev [Not Installed]                                                               
3)      libdap-dev [Not Installed]                                                                     
4)      libgdal-dev [Not Installed]                                                                    
5)      libgeotiff-dev [Not Installed]                                                                 
6)      libhdf4-alt-dev [Not Installed]                                                                
7)      libhdf5-dev [Not Installed]                                                                    
8)      libkml-dev [Not Installed]                          
9)      liblzma-dev [Not Installed]                         
10)     libmysqlclient-dev [Not Installed]                  
11)     libnetcdf-dev [Not Installed]                       
12)     libpng-dev [Not Installed]                          
13)     libspatialite-dev [Not Installed]                   
14)     libtiff-dev [Not Installed]                         
15)     uuid-dev [Not Installed]                            
16)     zlib1g-dev [Not Installed]                          



Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Downgrade the following packages:                                           
1)     liblzma5 [5.2.4-1ubuntu1 (now) -> 5.2.4-1 (focal)]                       
2)     libuuid1 [2.34-0.1ubuntu9.1 (now) -> 2.34-0.1ubuntu9 (focal)]            
3)     zlib1g [1:1.2.11.dfsg-2ubuntu1.2 (now) -> 1:1.2.11.dfsg-2ubuntu1 (focal)]

Accept this solution? [Y/n/q/?] Y

Now just to check run sudo apt install libgdal-dev

libgdal-dev is already the newest version (3.0.4+dfsg-1build3).

Hope this helps!!