交叉编译qt以及相关依赖软件

当前系统:ubuntu20 桌面版

本机软件安装:make cmake
安装目录 -extprefix /home/virtual/aarch64-qt
逻辑目录 -sysroot /home/virtual/sysroot

$ mkdir ~/aarch64-qt
$ mkdir ~/sysroot

将交叉编译器放到逻辑目录

$ sudo cp -r /usr/aarch64-linux-gnu/* sysroot/

编译qt,缺少openssl opengl fctix-qt

$ ./configure  -opensource -confirm-license -force-pkg-config -extprefix /home/virtual/aarch64-qt -xplatform linux-aarch64-gnu-g++  -qt-xcb  -nomake tests -nomake examples -sysroot /home/virtual/sysroot -no-gcc-sysroot -make tools

报错:

WARNING: Disabling pkg-config since PKG_CONFIG_LIBDIR is not set and
the host's .pc files would be used (even if you set PKG_CONFIG_PATH).
Set this variable to the directory that contains target .pc files
for pkg-config to function correctly when cross-compiling or
use -pkg-config to override this test.

WARNING: Python version 2 (2.7.5 or later) is required to build QtWebEngine.

ERROR: Feature 'pkg-config' was enabled, but the pre-condition 'tests.pkg-config' failed.

ERROR: Feature 'xcb' was enabled, but the pre-condition 'libs.xcb' failed.

ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.

Check config.log for details.

解决

WARNING: Python version 2 (2.7.5 or later) is required to build QtWebEngine.
----------------------------------------------
注意:在Qt 5.15构建要求中,提到使用Python 2.7.5或更高版本。不支持Python 3。   
删除配置文件,安装2.7,重新配置
$ rm -f config.cache
$ sudo apt-get install -y python2.7
$ sudo apt-get install -y libpython2.7
$ sudo ln -s /usr/bin/python2.7 /usr/bin/python

参考:Qt5 qmake-找不到合适的Python 2版本

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.
ERROR: Feature 'xcb' was enabled, but the pre-condition 'libs.xcb' failed.
需要交叉编译xcb来支持

交叉编译xcb

将下面命令中的--prefix=/home/virtual/aarch64-qt改为--prefix=/home/virtual/sysroot

$ wget https://xcb.freedesktop.org/dist/libxcb-1.5.tar.gz
$ wget https://xcb.freedesktop.org/dist/xcb-proto-1.6.tar.gz
$ tar -zxvf xcb-proto-1.6.tar.gz
$ cd xcb-proto-1.6/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/aarch64-qt --host=arm-linux
$ make -j16
$ make install

$ vim ~/.profile
	export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig:/home/virtual/sysroot/lib/pkgconfig"
$ source ~/.profile

$ sudo apt-get install xsltproc -y

$ wget https://xcb.freedesktop.org/dist/libpthread-stubs-0.4.tar.gz
$ tar -zxvf libpthread-stubs-0.4.tar.gz
$ cd libpthread-stubs-0.4/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/aarch64-qt --host=arm-linux
$ make -j16
$ make install

$ wget http://ports.ubuntu.com/pool/main/x/xorg-sgml-doctools/xorg-sgml-doctools_1.11.orig.tar.gz
$ tar -zxvf xorg-sgml-doctools_1.11.orig.tar.gz
$ cd xorg-sgml-doctools-1.11/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/aarch64-qt --host=arm-linux
$ make -j8
$ make install


$ wget https://xorg.freedesktop.org/archive/individual/proto/xproto-7.0.30.tar.gz
$ tar -zxvf xproto-7.0.30.tar.gz
$ cd xproto-7.0.30/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/aarch64-qt --host=arm-linux
$ make -j8
$ make install

$ wget https://xorg.freedesktop.org/archive/individual/lib/libXau-1.0.9.tar.gz
$ tar -zxvf libXau-1.0.9.tar.gz
$ cd libXau-1.0.9
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/aarch64-qt --host=arm-linux
$ make (如果这里报错,就将xproto的版本换成7.0.18)
$ make install

$ tar -zxvf libxcb-1.5.tar.gz
$ cd libxcb-1.5/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/aarch64-qt --host=arm-linux
$ make -j16
$ make install

参考:libxcb 交叉编译
CentOS7 环境下交叉编译(银河麒麟)

上面的xcb交叉编译按照顺序来,否则有依赖关系问题。

继续编译qt

按照上面的步骤安装完xcb后,还是报错xcb找不到,所以改用系统xcb,不用qt的,同时去掉-force-pkg-config选项,则编译选项更改为:

$ sudo ./configure  -opensource -confirm-license  -extprefix /home/virtual/aarch64-qt -xplatform linux-aarch64-gnu-g++  -xcb  -nomake tests -nomake examples -sysroot /home/virtual/sysroot -no-gcc-sysroot -make tools -no-opengl

编译通过。

$ sudo make -j16
$ sudo make install

make install时报错:

socketcanbackend.cpp:667:41: error: ‘SIOCGSTAMP’ was not declared in this scope
         if (Q_UNLIKELY(ioctl(canSocket, SIOCGSTAMP, &timeStamp) < 0)) {
                                         ^~~~~~~~~~

解决方法见我的交叉编译篇。

报错:

/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld.gold:错误: cannot find -lclip2tri
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld.gold:错误: cannot find -lpoly2tri
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld.gold:错误: cannot find -lclipper

解决:发现是location模块依赖的,跳过,新的配置如下

$ sudo ./configure  -opensource -confirm-license  -extprefix /home/virtual/aarch64-qt -xplatform linux-aarch64-gnu-g++  -xcb  -nomake tests -nomake examples -sysroot /home/virtual/sysroot -no-gcc-sysroot -make tools -no-opengl -qt-zlib -qt-libpng -skip qtlocation -skip qtscript -skip qtwayland

编译通过成功安装。

编译webengine

sudo ~/aarch64-qt/bin/qmake -r

报错:

ERROR: Feature 'pkg-config' was enabled, but the pre-condition 'tests.pkg-config' failed.

交叉编译pkgconfig

$ wget -c -t 20 https://pkg-config.freedesktop.org/releases/pkg-config-0.29.1.tar.gz
$ tar -zxvf pkg-config-0.29.1.tar.gz
$ cd pkg-config-0.29.1/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/sysroot --host=arm-linux --with-internal-glib

报错:

checking for growing stack pointer... configure: error: in `/home/virtual/pkg-config-0.29.1/glib':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
configure: error: ./configure failed for glib

需要安装交叉编译的glib,见交叉编译的另一篇中有glib内容。

交叉编译m4

$ wget https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
$ tar -zxvf m4-1.4.6.tar.gz
$ cd m4-1.4.6/
$ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/sysroot --host=arm-linux
$ make -j16
$ sudo make install

交叉编译autoconf

$ wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz
$ cd autoconf-2.65/
$ PATH=/home/virtual/sysroot/bin CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --prefix=/home/virtual/sysroot --host=arm-linux

报错:

./configure: line 424: sed: command not found
./configure: line 423: expr: command not found
./configure: line 424: sed: command not found
./configure: line 438: sed: command not found
: error: cannot create .lineno; rerun with a POSIX shell

expr命令是由下面的包提供的:

~$ apt-file  search  -F /usr/bin/expr
coreutils: /usr/bin/expr

报错:

checking for GNU M4 that supports accurate traces... configure: error: no acceptable m4 could be found in $PATH.
GNU M4 1.4.6 or later is required; 1.4.13 is recommended

系统安装m4:$ sudo apt install m4 -y

继续执行:

$ make -j16
# make install

交叉编译coreutils

不要使用coreutils-8.13这个版本,会报一个空文件的错误。
$ tar -zxvf coreutils-8.32.tar.gz
$ cd coreutils-8.32/
$ sudo CC=aarch64-linux-gnu-gcc ./configure --prefix=/home/virtual/sysroot --host=arm-linux
$ sudo make -j16
报错:
src/ls.c:3026:24: error: 'SYS_getdents' undeclared (first use in this function); did you mean 'SYS_getdents64'?
           if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
                        ^~~~~~~~~~~~
                        SYS_getdents64
按照提示修改,编译通过。
$ sudo make install

交叉编译sed

$ wget https://ftp.gnu.org/gnu/sed/sed-4.8.tar.gz
$ tar -zxvf sed-4.8.tar.gz
$ cd sed-4.8/
$ make -j16
$ sudo make install

将其他依赖全部安装到逻辑目录下

OPENSSL_LIBS=‘-L/usr/local/openssl/lib -lssl -lcrypto’ sudo ./configure -opensource -confirm-license --force-pkg-config -extprefix /home/uos/aarch64-qt -xplatform linux-aarch64-g++ -qt-xcb -nomake tests -nomake examples -sysroot / -no-gcc-sysroot -make tools -skip qtdoc -I /usr/local/openssl/include -L /usr/local/openssl/lib -ssl -openssl-linked -no-pch

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/bootleader/article/details/129561636