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

2 篇文章 0 订阅
1 篇文章 0 订阅

一 背景

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

二 根因

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

  • 在安装amd64版本时,会删除arm64版本,这会导致缺失libXRes.so的符号链接
    在这里插入图片描述
    在这里插入图片描述

  • 在安装arm64版本时,会删除amd64版本,这会导致缺失libXRes.so的符号链接
    在这里插入图片描述

    在这里插入图片描述

三 解决办法

手动创建缺少的动态库符号链接,比如创建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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-aarch64-gnu-g++ (arm64, CPU features: neon) Target compiler: gcc 6.3.1 Configuration: cross_compile use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus reduce_exports stl Build options: Mode ................................... release Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++14 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs Qt modules and options: Qt Concurrent .......................... yes Qt D-Bus ............................... yes Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Support enabled for: Using pkg-config ....................... yes udev ................................... no Using system zlib ...................... yes Qt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. yes ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no Qt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ yes Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... yes SCTP ................................... no Use system proxies ..................... yes Qt Gui: Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no Image formats: GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... yes PNG .................................. yes Using system libpng ................ no EGL .................................... no OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no OpenGL ES 3.2 ........................ no Vulkan ................................. no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon .............................. no X11 specific: XLib ................................. no EGL on X11 ........................... no QPA backends: DirectFB ............................... no EGLFS .................................. no LinuxFB ................................ yes VNC .................................... yes Mir client ............................. no Qt Sql: SQL item models ........................ yes Qt Widgets: GTK+ ................................... no Styles ................................. Fusion Windows Qt PrintSupport: CUPS ................................... no Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt Testlib: Tester for item models ................. yes Qt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yes Qt QML: QML network support .................... yes QML debugging and profiling support .... yes QML sequence object .................... yes QML list model ......................... yes QML XML http request ................... yes QML Locale ............................. yes QML delegate model ..................... yes Qt Quick: Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes TableView item ......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes Repeater item .......................... yes ShaderEffect item ...................... yes Sprite item ............................ yes Qt Scxml: ECMAScript data model for QtScxml ...... yes Qt Gamepad: SDL2 ................................... no Qt 3D: Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Use SSE2 instructions .................. no Use AVX2 instructions .................. no Aspects: Render aspect ........................ yes Input aspect ......................... yes Logic aspect ......................... yes Animation aspect ..................... yes Extras aspect ........................ yes Qt 3D Renderers: OpenGL Renderer ........................ yes Qt 3D GeometryLoaders: Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no Qt Bluetooth: BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no WinRT Bluetooth API (desktop & UWP) .... no Qt Sensors: sensorfw ............................... no Qt Quick Controls 2: Styles ................................. Default Fusion Imagine Material Universal Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... yes Qt Positioning: Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no Qt Location: Qt.labs.location experimental QML plugin . yes Geoservice plugins: OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. no Itemsoverlay ......................... yes QtXmlPatterns: XML schema support ..................... yes Qt Multimedia: ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Qt Tools: QDoc ................................... no Qt WebEngine: Embedded build ......................... yes Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. no Use System Ninja ....................... no Geolocation ............................ yes WebChannel support ..................... yes Use v8 snapshot ........................ yes Kerberos Authentication ................ no Building v8 snapshot supported ......... yes Use ALSA ............................... no Use PulseAudio ......................... no Optional system libraries used: re2 .................................. no icu .................................. no libwebp, libwebpmux and libwebpdemux . no opus ................................. no ffmpeg ............................... no libvpx ............................... no snappy ............................... no glib ................................. no zlib ................................. yes minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no x11 .................................. no Required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. no glibc ................................ yes Required system libraries for qpa-xcb: libdrm ............................... no xcomposite ........................... no xcursor .............................. no xi ................................... no xrandr ............................... no xtst ................................. no Note: Also available for Linux: linux-clang linux-icc
可以使用Linux下的FBDEV驱动来控制LCD液晶屏的显示,同时使用C/C++编写应用程序来实现字符串的显示。以下是一个简单的示例代码: ```c++ #include <fcntl.h> #include <linux/fb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <unistd.h> int main(int argc, char *argv[]) { int fbfd = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; char *fbp = 0; long int screensize = 0; int x = 0, y = 0; long int location = 0; // 打开Linux的framebuffer设备节点 fbfd = open("/dev/fb0", O_RDWR); if (fbfd == -1) { perror("Error: cannot open framebuffer device"); exit(1); } // 获取framebuffer的固定信息和可变信息 if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) { perror("Error reading fixed information"); exit(2); } if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) { perror("Error reading variable information"); exit(3); } // 计算framebuffer的大小 screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // 将framebuffer映射到内存中 fbp = (char *) mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if ((int) fbp == -1) { perror("Error: failed to map framebuffer device to memory"); exit(4); } // 清空屏幕 memset(fbp, 0, screensize); // 在屏幕上显示字符串 char *text = "班级:xxx 学号:xxx 姓名:xxx"; int len = strlen(text); for (int i = 0; i < len; i++) { if (text[i] == ' ') { // 空格 x += vinfo.bits_per_pixel / 8; } else { // 非空格 location = (x + vinfo.xoffset) * (vinfo.bits_per_pixel / 8) + (y + vinfo.yoffset) * finfo.line_length; *(fbp + location) = 0xFF; // blue *(fbp + location + 1) = 0xFF; // green *(fbp + location + 2) = 0xFF; // red *(fbp + location + 3) = 0xFF; // alpha x += vinfo.bits_per_pixel / 8; if (x >= vinfo.xres) { x = 0; y += 1; } } } // 解除内存映射 munmap(fbp, screensize); // 关闭framebuffer设备节点 close(fbfd); return 0; } ``` 需要注意的是,上述代码仅是一个示例,具体的LCD液晶屏显示方式可能会因不同的硬件而有所不同。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值