基于Windows10搭建QT的交叉编译

比较懒,一直在看,从未写过,但在这个事情上看了几篇讲解并按示例编译却总是失败,故写下自己成功的案例

0、参考链接(按示例编译失败的链接没有放)

Windows10 Qt5.14.2 arm交叉编译环境搭建QtCreator imx6ull - 欢迎来到江小鉴的博客

1、平台

Windows 10

ActivePerl 5.28

Python 3.12

Cmake 3.30.0-rc3 (如报cmake未发现则安装)

QT源码 qt-everywhere-src-5.14.2 (重要)

QTCreator qt-opensource-windows-x86-5.14.2 (重要)

交叉编译工具链 gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-linux-gnu

2、检查

(1)perl

(2)python

(3)cmake

(4)toolchain

3、解压QT源码,并配置交叉编译工具链

(1)将源码目录下qtquick3d删除(原因懒得测了)

(2)修改源码 qt-everywhere-src-5.14.2\qtbase\mkspecs\linux-aarch64-gnu-g++\qmake.conf 工具链(这里使用的 aarch64-none-linux-gnu 可根据需要替换,也可设置环境变量)

4、编译

(1)打开 qt-opensource-windows-x86-5.14.2 软件下的 Qt 5.14.2(MinGW 7.3.0 32-bit)(需要安装软件的时候选中安装该功能)

(2)进入源码目录

(3)配置编译选项,输入以下命令执行(具体为什么skip这些编译未测试,取消部分后要么配置失败要么编译失败)

configure.bat -release -opensource -prefix D:\D240307_WinOpensQT\demo\softw -nomake tests -nomake examples -no-opengl -skip qtvirtualkeyboard -skip qtwebengine -skip qt3d -skip qtquick3d -skip qttools -xplatform linux-aarch64-gnu-g++

(4)上述配置成功后(无打印Error信息)输入 mingw32-make -j4 执行(其中-j后跟的是编译线程数)

(5)编译成功后(无打印Error信息)执行安装命令 mingw32-make install(其中安装路径是上述配置中的 -prefix 后路径)

(6)安装后内容

5、打开QTCreator并配置kit组件(编译QT源码主要是要用qmake工具,其他的可以在编译工具链找到)

6、其他

        平台前提:最开始安装的QTCreator 12.0.2(QT 6.5.3),然后编译QT源码6.5.3、5.15.1等等均是各式各样的错误(#include <limits> #include <windows.h> ...),所以最终选择了软件+源码均是 5.14.2 来执行。

        上述使用工具:(阿li云盘)https://www.alipan.com/s/Qp3G5Xz6Bag 提取码: n2s0

        源码5.14.2链接:(gitee)git@gitee.com:whongfa/qt-everywhere-src-5.14.2.git

  • 25
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
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
要在 Buildroot 中搭建 Qt交叉编译环境,可以按照以下步骤进行操作: 1. 下载和配置 Buildroot:首先,从 Buildroot 官方网站上下载最新版本的 Buildroot。解压下载的压缩包后,进入 Buildroot 目录。 2. 配置 Buildroot:在 Buildroot 目录中执行 `make menuconfig` 命令,进入配置界面。在配置界面中,按照以下步骤进行配置: a. 选择目标平台:在 "Target options" 中,选择你的目标平台和处理器架构。 b. 选择 Qt 相关选项:在 "Toolchain" 中,选择 Qt 相关的选项,包括 "Enable Qt5" 和 "Enable Qt WebEngine"(如果需要)。 c. 配置交叉编译工具链:在 "Toolchain" 中,选择你希望使用的交叉编译工具链,或者自定义一个工具链。 d. 配置文件系统:在 "Filesystem images" 中,选择你希望生成的文件系统类型和格式。 e. 其他选项:根据你的需求,可以选择和配置其他选项,比如网络设置、软件包选择等。 f. 保存配置并退出:保存你的配置并退出配置界面。 3. 编译 Buildroot:回到 Buildroot 目录中,执行 `make` 命令来开始编译 Buildroot。这个过程可能需要一些时间,取决于你的系统性能和配置选项。 4. 安装生成的交叉编译工具链和文件系统:编译完成后,在 Buildroot 目录中的 `output` 目录下会生成交叉编译工具链和文件系统。将这些文件拷贝到你希望安装的位置。 5. 下载和配置 Qt:从 Qt 官方网站上下载适用于你的目标平台的 Qt 源代码包,并解压到一个目录中。进入解压后的 Qt 源代码目录。 6. 配置 Qt 编译选项:在 Qt 源代码目录中打开一个命令行终端,执行以下命令来配置 Qt 编译选项: ``` ./configure -prefix /path/to/qt/installation -device <device> -sysroot /path/to/buildroot/rootfs -opensource -confirm-license ``` 其中,`/path/to/qt/installation` 是你希望 Qt 安装到的目标路径。`<device>` 是你的目标设备名称,根据 Buildroot 的配置进行相应的替换。`/path/to/buildroot/rootfs` 是 Buildroot 生成的文件系统路径。 7. 编译 Qt:配置完成后,执行 `make` 命令来开始编译 Qt。这个过程可能需要一些时间,取决于你的系统性能和编译选项。 8. 安装 Qt:编译完成后,执行 `make install` 命令来安装 Qt 到指定的安装路径。 完成以上步骤后,你就成功搭建了 Buildroot 中的 Qt 交叉编译环境。现在你可以使用这个环境来编译运行在目标平台上的 Qt 应用程序了。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值