Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize QT5 Cross-compilation

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to achieve QT5 cross-compilation", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to achieve QT5 cross-compilation"!

Configure configuration. / configure-release-opensource-prefix-no-largefile-no-pkg-config-no-qml-debug-xplatform-qt-libpng-qt-zlib-qt-libjpeg-qt-freetype-qt-sql-sqlite-plugin-sql-sqlite-no-harfbuzz-no-openssl-no-libproxy-make libs-nomake tests-nomake examples-gui-widgets-no-cups-no-tslib-iconv-pch-no-c++11

Create a corresponding target tool compilation configuration directory under the qtbase/mkspecs/ directory based on similar platforms, such as linux-arm-gnueabi-g++ creation under the reference directory

QT_QPA_DEFAULT_PLATFORM option

The Qt Platform Abstraction (QPA) is the platform abstraction layer for Qt 5 and replaces Qt for Embedded Linux and the platform ports from Qt 4.

QT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS_RELEASE + =-O2-march=armv5te QMAKE_CXXFLAGS_RELEASE + =-O2-march=armv5te

QT_QPA_DEFAULT_PLATFORM is a must, usually cocoa on Mac, windows on window, and xcb on linuxX11. If there is OPENGL support, choose eglfs. For devices without hardware acceleration, choosing linuxfb,minimal just makes the program run away and has no effect (you can't see the interface). QPA is the abbreviation of QT Platform Abstraction.

Tslib represents QT's support for touchpads and requires additional links to the tslib library.-I and L are followed by the installation directories for compiling tslib's include and lib for the first step.

The version of Qt5.7 even needs to be compiled by the gcc compiler to support cantilever 11 in order to pass configure.

-c++std.. Compile Qt with C++ standard edition (11, 14, 1z) Default: highest supported

Qt5.6.2 and previous versions can be compiled with cached 98 by adding a configuration item of-no-c++11, prompting:

NOTICE: The-no-c++11 /-- c++-level=c++98 option is deprecated.Qt 5.7 will require Clearing 11 support. The options are in effect for thisQt 5.6 build, but you should update your build scripts to remove theoption and, if necessary, upgrade your compiler.Make build designated module make-j4 module-qtbase problem solving

Question 1: error: expected initializer before "throw"

I have solved the above problem myself. In the host directory / usr/include/i386-linux-gnu/sys/signalfd.h file, signalfd is defined as follows

Extern int signalfd (int _ _ fd, const sigset_t * _ _ mask, int _ flags) _ _ THROW _ nonnull ((2))

The definition of signalfd in the signalfd.h file under the Hayes cross-compilation tool catalog is as follows

Extern int signalfd (int _ fd, const sigset_t * _ _ mask, int _ flags) _ _ nonnull ((2)) _ _ THROW

Just switch _ _ nonnull ((2)) and _ _ THROW back and forth.

QPA plug-in compilation

Directory: qtbase/src/plugins/platforms library file: qtbase/plugins/platforms/

Running

Question 1: QT_QPA_DEFAULT_PLATFORM = linux # eglfs

#. / basiclayouts This application failed to start because it could not find or load the Qt platform plugin "linux # eglfs" in " Reinstalling the application may fix this problem. Aborted

Change the value of QT_QPA_DEFAULT_PLATFORM to linuxfb, and copy the plug-in libqlinuxfb.so to the development machine. The problem still arises, and the solution: set the appropriate environment variables.

Export QT_PLUGIN_PATH=/mnt/3520d/qt5.6.2/plugins

Copy the contents of the qtbase/src/plugins/platforms directory (the entire directory) to the directory specified by the environment variable.

Question 2: font file

#. / basiclayouts QFontDatabase: Cannot find font directory / home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts-is Qt installed correctly? QFontDatabase: Cannot find font directory / home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts-is Qt installed correctly? QFontDatabase: Cannot find font directory / home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts-is Qt installed correctly? QFontDatabase: Cannot find font directory / home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts-is Qt installed correctly?

Solution: set the font environment variable

Export QT_QPA_FONTDIR=/mnt/3520d/qt5.6.2/lib/fonts

Qt normally uses fontconfig to provide access to system fonts. If fontconfig is not available, Qt will fall back to using QBasicFontDatabase. In this case, Qt applications will look for fonts in Qt's lib/fonts directory. Qt will automatically detect pre-rendered fonts and TrueType fonts. This directory can be overridden by setting the QT_QPA_FONTDIR environment variable.

Display and interface

You can select response display plug-ins (eglfs, xcb, linuxfb, etc.) by setting the QT_QPA_PLATFORM environment variable or by specifying the-platform option on the command line.

LinuxFbexport QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1 mouse configuration

Linuxfb comes with libinput support, you just need to set the environment variable.

Export QT_QPA_EVDEV_MOUSE_PARAMETERS= "usb:/dev/event0"

To support hot-swappable, you need to build QT to support libudev:

Hot plugging is supported, but only if Qt was configured with libudev support (that is, if the libudev development headers are present in the sysroot at configure time). This allows connecting or disconnecting an input device while the application is running.

Keyboard configuration export QT_QPA_EVDEV_KEYBOARD_PARAMETERS= "usb:/dev/event3" picture support

PNG and JPEG format images are supported. You need to configure the corresponding options when building QT:

PNG:-qt-libpng. QT5 comes with JPG:-qt-libjpeg support, which requires compiler plug-in support.

For JPEG support, in addition to adding build options, you also need to copy the corresponding jpeg plug-in to the device in order to process the image correctly.

The image plug-in code directory is at: qtbase/src/plugins/imageformats

The successfully built plug-in library is located at: qtbase/plugins/imageformats

Copy the imageformats directory to the device and set the plug-in path environment variable for QT, which is the same as the previous QPA plug-in.

Export QT_PLUGIN_PATH=/mnt/3520d/qt5.6.2/plugins

In addition, JPEG images do not support transparency.

At this point, I believe that everyone on the "QT5 cross-compilation how to achieve" have a deeper understanding, might as well to actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report