Ubuntu “lib32ncurses5 : Depends: libc6-i386 (>= 2.18) but it is not going to be installed”类似问题解决办法

 

问题背景

在64位Linux操作系统的主机上安装32位的交叉编译链时,如果64位系统与32位的工具链不兼容,在我们使用工具链对代码进行交叉编译时,往往会出现明明工具链已经安装到了指定的目录下,环境变量也都设置好了,而系统却依旧提示与arm-XXX-linux-gnueabi-g++: error while loading shared libraries:libXXXXX.so.n: cannot open shared object file: no such file or directory类似的错误。

问题描述

想要让系统32-bit的交叉编译工具链正常工作,就需要安装lib32z1、lib32ncurses5、lib32stdc++6这几个兼容包。但是如果自己的系统里的libc6的版本比较高的话,在执行安装这几个兼容包时可能会出现类似下面的问题:

lch@ThinkPad:~$ sudo apt install lib32z1 lib32ncurses5 lib32stdc++6
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:
 lib32ncurses5 : Depends: lib32tinfo5 (= 6.0+20160213-1ubuntu1) but it is not going to be installed
                 Depends: libc6-i386 (>= 2.4) but it is not going to be installed
 lib32stdc++6 : Depends: lib32gcc1 (>= 1:4.2) but it is not going to be installed
                Depends: libc6-i386 (>= 2.18) but it is not going to be installed
 lib32z1 : Depends: libc6-i386 (>= 2.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

这里也许不太能看出这些包对libc6的版本依赖,我们再执行一下依赖包libc6-i386的安装,从提示可以明显看出libc6-i386依赖于2.23-0ubuntu11版本的libc6,而我的系统里libc6的版本为2.27-3ubuntu1。

lch@ThinkPad:~$ sudo apt-get install libc6-i386
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:
 libc6-i386 : Depends: libc6 (= 2.23-0ubuntu11) but 2.27-3ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.
Ubuntu “lib32ncurses5 : Depends: libc6-i386 (>= 2.18) but it is not going to be installed”类似问题解决办法_第1张图片 系统中libc6的版本

解决办法

针对这种情况,有两种解决办法:

1. 将自己系统里的libc6版本降级为2.23,对于操作系统里的各种部件不是十分熟悉的我来说这种方法的风险略大,一个不小心系统可能会崩在我的手里,稳妥起见,不考虑这种方案。

2. 直接安装与libc6_2.27-3ubuntu1版本匹配的软件包,即直接在网上寻找版本匹配的deb包。

下载地址链接:https://pkgs.org/

Ubuntu “lib32ncurses5 : Depends: libc6-i386 (>= 2.18) but it is not going to be installed”类似问题解决办法_第2张图片 网站界面

进入网页搜索所需的软件包,根据页面提示的软件包的版本及依赖关系下载相应的软件包并安装。要解决上述安装lib32z1、lib32ncurses5、lib32stdc++6安装过程中出现的问题,需要下载并安装下列软件包:

libc6-dev-i386_2.27-3ubuntu1_amd64.deb
libc6-i386_2.27-3ubuntu1_amd64.deb
gcc-8-base_8-20180414-1ubuntu2_amd64.deb
lib32gcc1_8-20180414-1ubuntu2_amd64.deb
lib32ncurses5_6.1-1ubuntu1_amd64.deb
lib32stdc++6_8-20180414-1ubuntu2_amd64.deb
lib32tinfo5_6.1-1ubuntu1_amd64.deb
lib32z1_1.2.11.dfsg-0ubuntu2_amd64.deb

注:网站上Ubuntu 16.04的软件包对应的libc6的版本是2.23,我需要安装的是2.27的,因而直接下载对应于2.27-3ubuntu1版本的Ubuntu 18.04的软件包,版本和依赖关系对应即可。 

安装之后查看交叉编译链版本,如打印出其详细的版本信息,说明成功解决。

Ubuntu “lib32ncurses5 : Depends: libc6-i386 (>= 2.18) but it is not going to be installed”类似问题解决办法_第3张图片 32位兼容包安装成功之后的交叉编译链打印的版本信息示例

你可能感兴趣的:(交叉编译环境搭建)