Linux x86_64平台同时编译x86_64和arm64两个架构的Qt应用程序出现XRes库无法找到

一 背景

在ubuntu x86_64平台上需要同时编译x86_64和arm64两个架构的Qt应用程序。在实践过程中,发现XRes库只能安装在其中一个平台。

二 根因

安装amd64版本的XRes库会删除arm64版本的库,反之亦然。

  • 在安装amd64版本时,会删除arm64版本,这会导致缺失libXRes.so的符号链接
    Linux x86_64平台同时编译x86_64和arm64两个架构的Qt应用程序出现XRes库无法找到_第1张图片
    Linux x86_64平台同时编译x86_64和arm64两个架构的Qt应用程序出现XRes库无法找到_第2张图片

  • 在安装arm64版本时,会删除amd64版本,这会导致缺失libXRes.so的符号链接
    Linux x86_64平台同时编译x86_64和arm64两个架构的Qt应用程序出现XRes库无法找到_第3张图片

    Linux x86_64平台同时编译x86_64和arm64两个架构的Qt应用程序出现XRes库无法找到_第4张图片

三 解决办法

手动创建缺少的动态库符号链接,比如创建arm64版本的符号链接,如下

sudo ln -s /usr/lib/aarch64-linux-gnu/libXRes.so.1.0.0 /usr/lib/aarch64-linux-gnu/libXRes.so

四 知识点

如何在x86_64系统下安装多架构包,比如arm64, 已实现交叉编译:

  • 需要添加arm64架构,如下指令:
dpkg --print-foreign-architectures
    i386
sudo dpkg --add-architecture arm64
dpkg --print-foreign-architectures
    i386
    arm64
  • 更改sources.list,因为默认的源不支持arm64, 只支持x86_64

需要注意添加arch,如下:[arch=arm64]
给出清华大学源,如下:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb [arch=amd64] http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb [arch=arm64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb [arch=arm64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb [arch=arm64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse

deb [arch=arm64] https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse

# deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse
# # deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
  • 执行更新:sudo apt-get update

以下给出在linux系统下开发图形应用程序一些常见的包,主要时x11相关的:

  • arm64版本
sudo apt-get -q -y install uuid-dev:arm64 libgl1-mesa-dev:arm64 libxcb-xkb-dev:arm64 freetds-dev:arm64 libfontenc-dev:arm64 libice-dev:arm64 libsm-dev:arm64 libxaw7-dev:arm64 libxt-dev:arm64 libxcomposite-dev:arm64 libxcursor-dev:arm64 libxi-dev:arm64 libxinerama-dev:arm64 libxkbfile-dev:arm64 libxmu-dev:arm64 libxmuu-dev:arm64 libxpm-dev:arm64 libxrandr-dev:arm64 libxrender-dev:arm64 libxres-dev:arm64 libxss-dev:arm64 libxtst-dev:arm64 libxv-dev:arm64 libxvmc-dev:arm64 libxcb-icccm4-dev:arm64 libxcb-image0-dev:arm64 libxcb-shm0-dev:arm64 libxcb-keysyms1-dev:arm64 libxcb-render-util0-dev:arm64 libxcb-xinerama0-dev:arm64 libxcb-util-dev:arm64 libxcb-shape0-dev:arm64 libxcb-randr0-dev:arm64 libxcb-xfixes0-dev:arm64 libxcb-sync-dev:arm64 libxcb-keysyms1-dev:arm64 libxkbcommon-x11-dev:arm64 libsm-dev:arm64 libice-dev:arm64 libqt5x11extras5-dev:arm64  libxcb-xinput-dev:arm64
  • amd64版本
sudo apt-get -q -y install uuid-dev:amd64 libgl1-mesa-dev:amd64 libxcb-xkb-dev:amd64 freetds-dev:amd64 libfontenc-dev:amd64 libice-dev:amd64 libsm-dev:amd64 libxaw7-dev:amd64 libxt-dev:amd64 libxcomposite-dev:amd64 libxcursor-dev:amd64 libxi-dev:amd64 libxinerama-dev:amd64 libxkbfile-dev:amd64 libxmu-dev:amd64 libxmuu-dev:amd64 libxpm-dev:amd64 libxrandr-dev:amd64 libxrender-dev:amd64 libxres-dev:amd64 libxss-dev:amd64 libxtst-dev:amd64 libxv-dev:amd64 libxvmc-dev:amd64 libxcb-icccm4-dev:amd64 libxcb-image0-dev:amd64 libxcb-shm0-dev:amd64 libxcb-keysyms1-dev:amd64 libxcb-render-util0-dev:amd64 libxcb-xinerama0-dev:amd64 libxcb-util-dev:amd64 libxcb-shape0-dev:amd64 libxcb-randr0-dev:amd64 libxcb-xfixes0-dev:amd64 libxcb-sync-dev:amd64 libxcb-keysyms1-dev:amd64 libxkbcommon-x11-dev:amd64 libsm-dev:amd64 libice-dev:amd64 libqt5x11extras5-dev:amd64  libxcb-xinput-dev:amd64

你可能感兴趣的:(linux,XRes,交叉编译,linux,ubuntu,qt)