QT cross compile ARM / CSKY

reference resources:

QT download address

Environmental Science:

ubuntu16. 04 (virtual machine)

QT version: QT everywhere src-5.12.9

Operation architecture: ARMV7 / CSKY

The target running architecture of cross compilation recorded below is ARMV7. At the same time, CSKY architecture has been tested. The cross compilation process of CSKY architecture is roughly the same, and some differences will be proposed in this paper.

1: Modify qmake Conf file

After extracting the QT source package, it will contain many function packages. The most basic and core qtbase package must be cross compiled. First, you need to modify or add qmake Conf file. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake. Qmake Conf file. This qmake The conf file will be used later when configuring configure.

When cross compiling ARM architecture, modify qtbase / mkspecs / linux-ARM-gnueabi-g + + / qmake Conf.

When cross compiling CSKY architecture, there is no appropriate file under qtbase/mkspecs /. Therefore, a new file named "linux-csky-g + +" is created by referring to the "linux-arm-gnueabi-g + +" file. Just modify qmake Conf file.

ARMV7 architecture modification qmake Conf is as follows:

  1 #
  2 # qmake configuration for building with arm-linux-gnueabi-g++
  3 #
  4 
  5 MAKEFILE_GENERATOR      = UNIX
  6 CONFIG                 += incremental
  7 QMAKE_INCREMENTAL_STYLE = sublib
  8 
  9 QT_QPA_DEFAULT_PLATFORM = linuxfb
 10 QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
 11 QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
 12 
 13 include(../common/linux.conf)
 14 include(../common/gcc-base-unix.conf)
 15 include(../common/g++-unix.conf)
 16 
 17 # modifications to g++.conf
 18 QMAKE_CC                = arm-linux-gnueabihf-gcc
 19 QMAKE_CXX               = arm-linux-gnueabihf-g++
 20 QMAKE_LINK              = arm-linux-gnueabihf-g++
 21 QMAKE_LINK_SHLIB        = arm-linux-gnueabihf-g++
 22 
 23 # modifications to linux.conf
 24 QMAKE_AR                = arm-linux-gnueabihf-ar cqs
 25 QMAKE_OBJCOPY           = arm-linux-gnueabihf-objcopy
 26 QMAKE_NM                = arm-linux-gnueabihf-nm -P
 27 QMAKE_STRIP             = arm-linux-gnueabihf-strip
 28 load(qt_config)
 29 

The "QMAKE_CFLAGS" variable can specify the flag parameter of C compiler during cross compilation, and the "QMAKE_CXXFLAGS" variable sets the flag parameter of C + + compiler. The specific parameter assignment is related to the cross tool chain. Qmake in CSKY architecture In conf, you can also use "QMAKE_CFLAGS" and "QMAKE_CXXFLAGS" variables to specify the CPU core type of the target SOC. Of course, the premise is that there are multiple cores in the SOC of your CSKY architecture. For other modifications, refer to the above code modification.

2: Use the configure script to configure compilation options

The configuration is very long. You can summarize the configuration items and write a compilation script. The compilation script I wrote is as follows for reference only.

  1 ./configure -prefix $(pwd)/arm-qt \
  2 -opensource \
  3 -confirm-license \
  4 -release \
  5 -strip \
  6 -shared \
  7 -xplatform linux-arm-gnueabi-g++ \
  8 -optimized-qmake \
  9 -c++std c++11 \
 10 --rpath=no \
 11 -pch \
 12 -skip qt3d \
 13 -skip qtactiveqt \
 14 -skip qtandroidextras \
 15 -skip qtcanvas3d \
 16 -skip qtconnectivity \
 17 -skip qtdatavis3d \
 18 -skip qtdoc \
 19 -skip qtgamepad \
 20 -skip qtlocation \
 21 -skip qtmacextras \
 22 -skip qtnetworkauth \
 23 -skip qtpurchasing \
 24 -skip qtremoteobjects \
 25 -skip qtscript \
 26 -skip qtscxml \
 27 -skip qtsensors \
 28 -skip qtspeech \
 29 -skip qtsvg \
 30 -skip qttools \
 31 -skip qttranslations \
 32 -skip qtwayland \
 33 -skip qtwebengine \
 34 -skip qtwebview \
 35 -skip qtwinextras \
 36 -skip qtx11extras \
 37 -skip qtxmlpatterns \
 38 -make libs \
 39 -make examples \
 40 -nomake tools -nomake tests \
 41 -gui \
 42 -widgets \
 43 -dbus-runtime \
 44 --glib=no \
 45 --iconv=no \
 46 --pcre=qt \
 47 --zlib=qt \
 48 -no-openssl \
 49 --freetype=qt \
 50 --harfbuzz=qt \
 51 -no-opengl \
 52 -linuxfb \
 53 --xcb=no \
 54 -tslib \
 55 --libpng=qt \
 56 --libjpeg=qt \
 57 --sqlite=qt \
 58 -plugin-sql-sqlite \
 59 -no-tslib \
 60 -recheck-all

Where the - xplatform parameter specifies qmake The folder where conf is located- Skip parameter can skip not compiling the corresponding function package, otherwise the compilation time will be very long. - no tslib in line 59 indicates that tslib controls are not supported. If you need to use tslib to realize the touch function, you need to cross compile tslib first. Then use the "- I" parameter to specify the include file of the cross compiled tslib installation directory. Use the "- L" parameter to specify the lib file of the cross compiled tslib installation directory.

Then execute the compilation Script Compilation. Note that g + + needs to be installed in PC linux. Execute sudo apt get install g + +. When the prompt "Qt is now configure for building just run make" appears. You can start compiling the source code with make.

3: Execute make to start compilation

During make compilation, the ARM architecture did not encounter any problems. The CSKY architecture will report errors in one place. The error information is as follows:

error Target architecture was not detected as supported by Double-Conversion.

The prompt message is that the CSKY architecture does not support double conversion in the QT source code. This problem can be solved by modifying QT source code in qtbase / SRC / 3rdparty / double conversion / include / double conversion / utils H file, add the macro definition of CSKY at the position shown in the figure below.

After making, execute make install to install the cross compiled files in the directory specified by the -- prefix parameter during configuration.

4: Migrate to root file system test

My root file system is generated using buildroot. Of course, buildroot can also generate QT. Copy the arm QT file obtained from the above cross compilation to the / usr/lib / directory of rootfs, then edit / etc/profile and add the following contents for reference only.

 11 export QT_ROOT=/usr/lib/arm-qt
 12 export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event1
 13 export QT_QPA_FONTDIR=/usr/share/fonts/liberation/
 14 export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
 15 export QT_PLUGIN_PATH=$QT_ROOT/plugins
 16 export QT_LIBRARY_PATH=$QT_ROOT/lib:$QT_ROOT/plugins/platforms
 17 export QML2_IMPORT_PATH=$QT_ROOT/qml
 18 export QT_QPA_FB_TSLIB=1
 19 
 20 export LD_LIBRARY_PATH=$PKG_CONFIG_PATH:\
 21 /usr/lib/arm-qt/lib

After specifying QT environment variables in rootfs, you need to refresh the / etc/profile file. You can refresh it by using the source /etc/profile command. Then you can execute the demo program provided by QT to judge whether the migration is correct. The path is as follows

/usr/lib/arm-qt/examples/widgets/animation/animatedtiles/animatedtiles 

Keywords: Qt

Added by eheia on Mon, 24 Jan 2022 11:27:44 +0200