1. 更新apt-get的源为国内源
自带的apt-get源,下载速度慢。最好更新为国内源。
要更新为国内源,需要编辑配置文件/etc/apt/sources.list
。
$ sudo vim /etc/apt/sources.list
安装的Ubuntu的版本为20.04,需要找到与版本相匹配的国内源。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
在更新国内源时,需要注意国内源所提供的版本是否与安装的Ubuntu一致。否则会出现无法安装的问题。
root@go-gdal:~# apt-get install libgdal-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libgdal-dev : Depends: libc6-dev but it is not going to be installed
Depends: libarmadillo-dev but it is not going to be installed
Depends: libdap-dev but it is not going to be installed
Depends: libexpat1-dev but it is not going to be installed
Depends: libgeotiff-dev 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: libjpeg-dev
Depends: libkml-dev but it is not going to be installed
Depends: libltdl-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: libpcre3-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: libsqlite3-dev but it is not going to be installed
Depends: libtiff-dev but it is not going to be installed
Depends: libxerces-c-dev but it is not going to be installed
Depends: libxml2-dev but it is not going to be installed
Depends: unixodbc-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
参考
[1] Ubuntu 20.04 阿里云镜像、国内源
[2] ubuntu使用apt安装包提示 g++ : Depends: g+±5 (>= 5.3.1-3~) but it is not going to be installed 缺少依赖包
[3] go gdal库 配置应用