ubuntu安装libzstd-dev

前端之家收集整理的这篇文章主要介绍了ubuntu安装libzstd-dev前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

使用apt-get 安装

某个项目需要使用libzstd-dev库,安装步骤如下:

  • 获取sudo权限
  • apt-get update
  • apt-get libzstd-dev

报错,错误如下(E: Unable to locate package libzstd-dev):

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libzstd-dev

使用deb包安装

步骤:

  • 下载deb包libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb
  • 安装命令dpkg -i libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb

报错,阿里云上的机器报错如下:

dpkg-deb: error: archive 'libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz',giving up
dpkg: error processing archive libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb (--install):
 subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
 libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb

或者,本地机器报错如下:

Selecting prevIoUsly unselected package libzstd-dev:amd64.
(Reading database ... 59755 files and directories currently installed.)
Preparing to unpack libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb ...
Unpacking libzstd-dev:amd64 (1.3.3+dfsg-2ubuntu1) ...
dpkg: dependency problems prevent configuration of libzstd-dev:amd64:
 libzstd-dev:amd64 depends on libzstd1 (= 1.3.3+dfsg-2ubuntu1); however:
  Package libzstd1 is not installed.

dpkg: error processing package libzstd-dev:amd64 (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 libzstd-dev:amd64

可以看出,本地机器报错是因为需要安装依赖,这是dpkg的缺点,不能自动安装依赖包,由于不清楚还需要依赖多少层,所以放弃。
而阿里云的报错是因为dpkg命令本身报错,dpkg没有安装好,但同样放弃,因为就算修复了dpkg,最后也会陷入依赖的漩涡。

更新dep源后,使用apt-get安装

通过google,百度等等,找到了一个类似的解决方法
https://superuser.com/questions/467774/how-to-install-libfaac-dev

于是照做,在/etc/apt/sources.list中加入了

deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb http://archive.ubuntu.com/ubuntu natty main restricted universe multiverse

后执行apt-get update 报错,通过报错信息发现natty有问题
http://archive.ubuntu.com/ubuntu/dists/ 下并没有natty文件夹,需要修改

如何修改呢?
https://launchpad.net/ubuntu/+source/libzstd 下发现 可以选择 Cosmic Bionic Artful Xenial, 随便选了一个bionic
即在/etc/apt/sources.list 中加入了

deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse

后执行 apt-get update,没有报错了。
继续 apt-get libzstd-dev,仍然报错,报错信息如下:

dpkg-deb: error: archive '/var/cache/apt/archives/libzstd1_1.3.3+dfsg-2ubuntu1_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz',giving up
dpkg: error processing archive /var/cache/apt/archives/libzstd1_1.3.3+dfsg-2ubuntu1_amd64.deb (--unpack):
 subprocess dpkg-deb --control returned error exit status 2
dpkg-deb: error: archive '/var/cache/apt/archives/libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz',giving up
dpkg: error processing archive /var/cache/apt/archives/libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb (--unpack):
 subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/libzstd1_1.3.3+dfsg-2ubuntu1_amd64.deb
 /var/cache/apt/archives/libzstd-dev_1.3.3+dfsg-2ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

安装 Gdebi

怀疑是dpkg本身损坏,于是根据这个又搜到了http://forum.ubuntu.org.cn/viewtopic.php?t=387768
按照这个安装 apt-get install gdebi
需要提前apt-get install -y libc6-dev apt-get install -y dpkg-dev
安装gdebi后,再次安装 libzstd-dev,仍然失败,错误信息没变,事情陷入困局。

解决

其实在前面有一步离问题解决已经十分接近了,最后,经过反复尝试,解决方法如下:

  • 在/etc/apt/sources.list 中加入

    deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
    deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
  • apt-get update

  • apt-get install libzstd-dev 安装成功
原文链接:https://www.f2er.com/ubuntu/349508.html

猜你在找的Ubuntu相关文章