在hisi上QT交叉编译过程(带webengine)

服务器:ubuntu 16.04 LTS server_64bit
1、安装交叉编译器
海思:aarch64-himix100-linux
PATH导出交叉编译器

2、下载和解压QT源码5.9.6
http://download.qt.io/archive/qt/

3、配置configure脚本build.sh
内容如下:
#!/bin/bash

./configure -v \
        -prefix /usr/local/qtembedded-5.9.0-arm \
        -recheck-all -verbose \
        -opensource -confirm-license -release -shared \
        -xplatform linux-aarch64-gnu-g++ \
        -no-pch -no-rpath \
        -sysroot /home/he_liangbin/aarch64-himix100-linux/target \
        -no-gcc-sysroot -pkg-config \
        -nomake examples -nomake tests -make libs -dbus-linked -widgets -accessibility \
        -icu -no-glib -qt-pcre -qt-zlib \
        -openssl-linked -L/home/he_liangbin/aarch64-himix100-linux/target/usr/lib/ -I/home/he_liangbin/aarch64-himix100-linux/target/usr/include/openssl \
        -no-cups -fontconfig -qt-freetype  \
        -no-opengl -no-directfb -no-eglfs -no-kms -linuxfb -no-xcb \
        -evdev -no-libinput -no-tslib -libudev -no-mtdev \
        -qt-libjpeg -qt-libpng \
        -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite2 -no-sql-tds \
        -no-alsa

/usr/local/qtembedded-5.9.0-arm : Qt安装目录
linux-aarch64-gnu-g++:qtbase/mkspec/支持的交叉编译器
/home/he_liangbin/aarch64-himix100-linux/target:指向交叉编译器安装目录

运行该配置脚本,打印如下错误:
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.

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

ERROR: Feature 'dbus-linked' was enabled, but the pre-condition 'features.dbus && libs.dbus' failed.

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

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

ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && libs.openssl' failed.

ERROR: Feature 'openssl' was enabled, but the pre-condition '!features.securetransport && (features.openssl-linked || libs.openssl_headers)' failed.

ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 && !config.darwin && features.system-freetype && libs.fontconfig' failed

按照下面步骤解决,先创建sourcecode和qt_deplib,前者存放第三方库源码,后者用于第三方库安装目录
        
4、设置pkg-config
$HOME/.profile or /etc/profile文件添加:
export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"

5、安装libdbus
(1)先安装:expat-2.2.6.tar.bz2
./configure --prefix=/home/he_liangbin/qt_deplib/expat --host=aarch64-himix100-linux 
make
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/expat/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/
cp /home/he_liangbin/qt_deplib/expat/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

否则编译dbus出现如下错误:
configure: error: Explicitly requested expat but expat not found

(2)下载源码:dbus-1.10.26.tar.gz
解压进入目录:dbus-1.10.26 
./configure --prefix=/home/he_liangbin/qt_deplib/dbus-1 --host=aarch64-himix100-linux LIBS=-L/home/he_liangbin/qt_deplib/expat/lib CPPFLAGS=-I/home/he_liangbin/qt_deplib/expat/include
make
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/dbus-1/include/dbus-1.0/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/dbus-1/lib/dbus-1.0/include/dbus/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/dbus
cp /home/he_liangbin/qt_deplib/dbus-1/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

6、安装libudev
(1)该方法没有动态库:
udev:
./configure --enable-shared --prefix=/home/helb/opencode/udev-167/tmp/udev-167/_install --host=aarch64-himix100-linux CFLAGS="-mcpu=cortex-a73.cortex-a53" LDFLAGS="-mcpu=cortex-a73.cortex-a53" --disable-extras --disable-introspection
make OSDRV_CROSS=aarch64-himix100-linux-
(2)使用下面方法:
eudev:
https://blog.csdn.net/Webster_WXH/article/details/80839426
./configure --prefix=/home/he_liangbin/qt_deplib/eudev -host=aarch64-himix100-linux 
服务器需要安装gperf,否则不过
sudo apt-get install gperf

make
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/eudev/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/
cp /home/he_liangbin/qt_deplib/eudev/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

7、编译ICU
参考文章:http://javacave.blogspot.com/2013/12/icu-521-for-android-window-mingw-64msys.html
tar xf icu4c-59_1-src.tgz
同级目录建立: mkdir icupc
cd icupc
../icu/source/runConfigureICU Linux/gcc
make
cd ../icu/source
./configure --host=aarch64-himix100-linux --prefix=/home/he_liangbin/qt_deplib/icu --disable-samples --disable-tests --with-cross-build=/home/he_liangbin/sourcecode/icupc
make 
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/icu/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/icu/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

8、安装openssl
参考文章:https://www.cnblogs.com/liangwode/p/5580230.html
tar xf openssl-1.0.2l.tar.gz
注:不能使用openssl-1.1.0
cd openssl-1.0.2l
先配置
./config no-asm shared --prefix=/home/he_liangbin/qt_deplib/openssl --openssldir=/home/he_liangbin/qt_deplib/openssl
修改Makefile:
CROSS_COMPILE= aarch64-himix100-linux-
CC= cc to CC= $(CROSS_COMPILE)gcc
AR= ar $(ARFLAGS) r to AR= $(CROSS_COMPILE)ar $(ARFLAGS) r
RANLIB= /usr/bin/ranlib to RANLIB= $(CROSS_COMPILE)ranlib 
删除两处 -m64

make 
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/openssl/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/openssl/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

修改Qt的build.sh:
-openssl-linked -L/home/he_liangbin/aarch64-himix100-linux/target/usr/lib/ -I/home/he_liangbin/aarch64-himix100-linux/target/usr/include/openssl \

openssl-1.1.0编译方法(备注而已):
export cross=aarch64-himix100-linux-
./Configure dist --prefix=/home/he_liangbin/qt_deplibt/openssl-1.1.0  shared
make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"

9、编译fontconfig
tar xf fontconfig-2.12.0.tar.gz
fontconfig依赖free-type依赖

(1)编译free-type
tar xf freetype-2.8.tar.gz
./configure CC=aarch64-himix100-linux-gcc --prefix=/home/he_liangbin/qt_deplib/fontconig --host=aarch64-himix100-linux  --without-zlib
make
make install
导出pkg-config
vi $HOME/.profile or /etc/profile文件添加:
export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig:/home/he_liangbin/qt_deplib/fontconig/lib/pkgconfig"

(2)编译expat
前面已经编译
导出pkg-config
vi $HOME/.profile or /etc/profile文件添加:
export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig:/home/he_liangbin/qt_deplib/fontconig/lib/pkgconfig:/home/he_liangbin/qt_deplib/expat/lib/pkgconfig"

(3)编译fontconig
./configure CC=aarch64-himix100-linux-gcc --prefix=/home/he_liangbin/qt_deplib/fontconig --host=aarch64-himix100-linux --with-arch=arm64
make
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/fontconig/include/fontconfig /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/fontconig/include/freetype2/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/fontconig/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

10、编译QT
make 

11、单独编译qtwebengine
以上编译了其他模块,还不能编译qtwebengine,通过以下验证:
../qtbase/bin/qmake -r

需要导出dbus-1和fontconfig的pkg-config:
export PKG_CONFIG_PATH="/usr/lib/pkgconfig:/home/he_liangbin/qt_deplib/fontconig/lib/pkgconfig:/home/he_liangbin/qt_deplib/expat/lib/pkgconfig:/home/he_liangbin/qt_deplib/dbus-1/lib/pkgconfig"

还是有如下错误,导致不编译:
khronos development headers appear to be missing (mesa/libegl1-mesa-dev)
缺少头文件,从系统中拷贝KHR:
cp /usr/include/KHR /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf

出现错误:
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
安装以下几个库:
apt-get install gperf flex bison

出现错误:error: ‘QOpenGLContext’ does not name a type
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();

if (QOpenGLContext *context = qt_gl_global_share_context()) {
给屏蔽再编译

12、进入源码根目录
make 
make install


参考网站:
https://blog.csdn.net/godofdsp/article/details/50961853
https://blog.csdn.net/sanallen/article/details/80954964
https://blog.csdn.net/viewsky11/article/details/73776747
http://wiki.qt.io/Building_Qt_5_from_Git#Getting_the_source_code
https://blog.csdn.net/zzwdkxx/article/details/67636280
http://wiki.qt.io/QtWebEngine/How_to_Try
http://www.qter.org/forum.php?mod=viewthread&tid=5959
https://blog.csdn.net/sanallen/article/details/80954964
https://stackoverflow.com/questions/47100545/how-to-build-qtwebengine-5-10-from-source


交叉编译:
https://forum.qt.io/topic/80664/getting-error-qtwebengine-module-build-install-for-cross-compiling/7
https://github.com/Kukkimonsuta/rpi-buildqt/tree/dev

以下第三方编译暂时用不到:
(1)zlib:
export CC=aarch64-himix100-linux-gcc 
./configure --prefix=/home/he_liangbin/qt_deplib/zlib
make
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/zlib/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/
cp /home/he_liangbin/qt_deplib/zlib/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

(2)libpng16和libjepg:
./configure --prefix=/home/he_liangbin/qt_deplib/libpng --host=aarch64-linux-gnu
make
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/libpng/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/libpng/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

./configure --prefix=/home/he_liangbin/qt_deplib/libjpeg  --host=aarch64-himix100-linux  CC=aarch64-himix100-linux-gcc --enable-shared --enable-static
make
make install
拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/libjpeg/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ 
cp /home/he_liangbin/qt_deplib/libjpeg/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

(3)xproto(pkg-config用到):
https://www.x.org/archive/individual/proto/

glproto-1.4.17:
./configure  --prefix=/home/he_liangbin/qt_deplib/xproto  --host=aarch64-himix100-linux
make install

dri2proto-2.8:
无法交叉编译,就用gcc配置,安装头文件而已
./configure  --prefix=/home/he_liangbin/qt_deplib/xproto
make install

xcb-proto-1.12:
CC=aarch64-himix100-linux-gcc CXX=aarch64-himix100-linux-g++ 
./configure --prefix=/home/he_liangbin/qt_deplib/xproto --host=aarch64-himix100-linux
make install

拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/xproto/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
导出pkg-config:


(4)xcb:
CC=aarch64-himix100-linux-gcc CXX=aarch64-himix100-linux-g++ 
./configure --prefix=/home/he_liangbin/qt_deplib/libxcb --host=aarch64-himix100-linux
make
依赖太多,编译不过


(5)libdrm:
CC=aarch64-himix100-linux-gcc CXX=aarch64-himix100-linux-g++
./configure --prefix=/home/he_liangbin/qt_deplib/libdrm --target=aarch64-himix100-linux --host=aarch64-himix100-linux --disable-cairo-tests
make
make install
拷贝头文件和库文件到交叉编译安装目录target/user下面:
cp /home/he_liangbin/qt_deplib/libdrm/include/* /home/he_liangbin/aarch64-himix100-linux/target/usr/include/ -rf
cp /home/he_liangbin/qt_deplib/libdrm/lib/* /home/he_liangbin/aarch64-himix100-linux/target/usr/lib/

(6)pthred_stubs:
无法交叉编译,就用gcc配置,安装头文件而已
./configure --prefix=/home/he_liangbin/qt_deplib/libpthread_stubs
make install
导出pkg-config:


(7)mesa:
CC=aarch64-himix100-linux-gcc CXX=aarch64-himix100-linux-g++ 
./configure --prefix=/home/he_liangbin/qt_deplib/mesa --target=aarch64-himix100-linux --host=aarch64-himix100-linux --enable-gles2 --enable-gles1 --disable-glx --disable-egl --disable-dri --enable-shared-glapi  --with-dri-drivers=swrast
./configure --prefix=/home/he_liangbin/qt_deplib/mesa --target=aarch64-himix100-linux --host=aarch64-himix100-linux --enable-shared-glapi
make
依赖太多,编译不过

你可能感兴趣的:(linux应用)