交叉编译 armhf 并安装静态库

psi*_*i75 5 compiling arm cross-compilation

我已经设置了一个交叉编译的 docker 实例。简而言之,我开始设置

apt-get update
apt-get install binutils-multiarch

dpkg --add-architecture armhf
# Manually add correct armhf repositories to /etc/apt/sources.list
apt-get update
apt-get install libudev-dev:armhf
Run Code Online (Sandbox Code Playgroud)

在这最后一步中,我收到以下错误:

The following packages have unmet dependencies:
libudev-dev:armhf : Depends: libacl1:armhf (>= 2.2.51-8) but it is not going to be installed
                    Depends: libblkid1:armhf (>= 2.19.1) but it is not going to be installed
                    Depends: libc6:armhf (>= 2.17) but it is not going to be installed
                    Depends: libgcc1:armhf (>= 1:3.5) but it is not going to be installed
                    Depends: libkmod2:armhf (>= 5~) but it is not going to be installed
                    Depends: libselinux1:armhf (>= 2.0.65) but it is not going to be installed
                    Depends: libudev1:armhf (= 229-4ubuntu4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

手动安装这些不是一个选项,因为libc6:armhf与当前安装的 amd64 libc6 冲突,最终会覆盖这个包。我只想设置libudev:armhf包,以便我可以链接到它。

/etc/apt/sources.list

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial main restricted
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates universe

deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security multiverse
Run Code Online (Sandbox Code Playgroud)

运行apt-cache policy libudev-dev:{amd64,armhf}输出如下:

libudev-dev:
  Installed: (none)
  Candidate: 229-4ubuntu21.4
  Version table:
     229-4ubuntu21.4 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
     229-4ubuntu21.1 500
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
     229-4ubuntu4 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libudev-dev:armhf:
  Installed: (none)
  Candidate: 229-4ubuntu4
  Version table:
     229-4ubuntu4 500
        500 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf Packages
Run Code Online (Sandbox Code Playgroud)

Oli*_*jon 6

第 1 步 - 打开终端:

Ctrl+ Alt+ T

第 2 步 - 备份:

执行:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
Run Code Online (Sandbox Code Playgroud)

第 3 步 - 打开编辑器:

执行:

sudo gedit /etc/apt/sources.list
Run Code Online (Sandbox Code Playgroud)

如果需要,您可以使用其他编辑器。

第 4 步 - 编辑sources.list

删除这里的所有内容并添加这些:

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial main multiverse restricted universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial main multiverse restricted universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates main multiverse restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security main multiverse restricted universe
Run Code Online (Sandbox Code Playgroud)

保存并退出。

第 5 步 - 更新您的存储库索引:

执行:

sudo apt update
Run Code Online (Sandbox Code Playgroud)

第 6 步 -libudev-devarmhf架构安装:

执行:

sudo apt install libudev-dev:armhf
Run Code Online (Sandbox Code Playgroud)

说明: Multiarch 包需要在所有架构上安装相同的版本。所以,你应该有libudev-dev:armhfversion 229-4ubuntu21.4,但你当前的存储库配置不包括这个版本。因此,您应该添加xenial-updates支持此版本的行。

关于其他建议添加频道,我建议您添加这些以防出现问题。