由于hisiv300不支持c++11,无法编译webengine,故只好选择编译webkit。编译webkit依赖pkg-config、libudev、fontconfig、openssl和icu,参考博文《在hisi上QT交叉编译过程(带webengine)》[1]。
a) 开启pkg-config
a) 首先保证Ubuntu虚拟机安装了pkg-config(我的机器安装的是pkg-config-0.29)
b) 设置路径/etc/profile文件添加:
export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"
c) 设置pkg-config根目录
在对Qt源代码进行configure之前,输入命令行PKG_CONFIG_SYSROOT_DIR=/进行根目录设置
b) 编译libudev
在https://github.com/gentoo/eudev/tree/rule_generator_eudev3下载eudev-rule_generator_eudev3.zip解压,Ubuntu需要安装gperf,否则编译不过:
sudo apt-get install gperf
在eudev源代码根目录输入:
i. ./autogen.sh
ii. ./configure --prefix=/home/crystal/qt_deplib/eudev --host=arm-hisiv300-linux CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --disable-blkid --disable-kmod
iii. make
Make时出错:program_invocation_short_name
参考《关于c语言中的program_invocation_short_name》博文[2]将用到 program_invocation_short_name 这个变量的地方全部用执行的字符串代替,比如,在编译eudev时,直接用"udev"替换 program_invocation_short_name 这个变量。然后重新make。
i) make
ii) makeinstall
iii) sudo cp /home/crystal/qt_deplib/eudev/include/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/
iv) sudo cp /home/crystal/qt_deplib/eudev/lib/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
c) 编译fontconfig
编译fontconfig依赖free-type和expat,下面分别交叉编译这三个库。
i. 编译free-type
下载
./configure --enable-static=yes --host=arm-hisiv300-linux --prefix=/home/crystal/qt_deplib/fontconig CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --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"
sudo cp /home/crystal/qt_deplib/fontconig/include/freetype2/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/ -rf
sudo cp /home/crystal/qt_deplib/fontconig/lib/libfreetype.* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
ii. 编译expat
下载源代码expat-2.2.6.tar.bz2解压
./configure --prefix=/home/crystal/qt_deplib/expat --host=arm-hisiv300-linux CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --enable-static
make
make install
sudo cp /home/crystal/qt_deplib/expat/include/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/
sudo cp /home/crystal/qt_deplib/expat/lib/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
iii. 编译libdbus(此库是否需要不确定,以下是编译方法)
下载源代码dbus-1.10.26.tar.gz解压
./configure --prefix=/home/crystal/qt_deplib/expat --host=arm-hisiv300-linux CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --enable-static
make
make install
sudo cp /home/crystal/qt_deplib/expat/include/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/
sudo cp /home/crystal/qt_deplib/expat/lib/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
iv. 编译libxml2(此库是否需要不确定,以下是编译方法)
./configure --host=arm-hisiv300-linux --prefix=/home/crystal/qt_deplib/libxml2 --enable-static=yes CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --with-python=no --with-zlib=no --with-lzma=no
make
make install
sudo cp /home/crystal/qt_deplib/libxml2/include/libxml2 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/ -rf
sudo cp /home/crystal/qt_deplib/libxml2/lib/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
v. 编译fontconfig
下载fontconfig-2.8.0.tar.gz,解压,编译。
./configure --enable-static=yes --enable-shared=no --host=arm-hisiv300-linux --prefix=/home/crystal/qt_deplib/fontconig CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --without-png
make
make install
sudo cp /home/crystal/qt_deplib/fontconig/include/fontconfig /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/ -rf
sudo
cp /home/crystal/qt_deplib/fontconig/include/freetype2/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/ -rf
sudo cp /home/crystal/qt_deplib/fontconig/lib/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
d) 编译openssl
下载安装包openssl-1.0.2l.tar.gz解压
./config linux-generic32 no-asm static no-async --prefix=/home/crystal/qt_deplib/openssl --openssldir=/home/crtstal/qt_deplib/openssl CROSS_COMPILE= arm-hisiv300-linux- CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++
修改Makefile:
CROSS_COMPILE= arm-hisiv300-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下面:
sudo cp /home/crystal/qt_deplib/openssl/include/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/ -rf
sudo cp /home/crystal/qt_deplib/openssl/lib/.a /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
e) 编译icu
一开始下载icu4c-59_2-src.tgz,解压编译怎么都通不过,因为arm-hisiv300不支持c++11,后面经过多次尝试,下载icu4c-51_2-src.tgz解压编译通过。编译过程如下:
mkdir icupc
cd ./icupc
…/icu/source/runConfigureICU Linux/gcc
make
cd …/icu/source
./configure --enable-static=yes --enable-shared=no --host=arm-hisiv300-linux --disable-samples --disable-tests --prefix=/home/crystal/qt_deplib/icu CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++ --with-cross-build=/home/crystal/icupc
make
make install
sudo cp /home/crystal/qt_deplib/icu/include/ /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/ -rf
sudo cp /home/crystal/qt_deplib/icu/lib/* /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/lib/
f) 编译Qt
进入Qt5.5.1源代码根目录,执行下面命令:
PKG_CONFIG_SYSROOT_DIR=/ ./configure -v -prefix /opt/qt5.5.1-v300-static -static -opensource -release -confirm-license -make libs -xplatform linux-arm-gnueabi-g++ -optimized-qmake -widgets -gui -accessibility -pch -alsa -linuxfb -fontconfig -mtdev -evdev -openssl -icu -strip -qt-sql-sqlite -qt-libjpeg -qt-libpng -qt-zlib -qt-freetype -pkg-config -no-tslib -no-rpath -no-journald -no-c++11 -no-glib -no-directfb -no-xcb -no-sse2 -no-openssl -no-nis -no-cups -no-kms -no-opengl -no-largefile -no-pulseaudio -no-qml-debug -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -no-compile-examples -nomake examples -nomake tools -nomake tests
然后make,编译到webkit里的JavaScriptCore时,报错:runtime/JSCJSValue.h:101:1: error: ‘JS_EXPORT_PRIVATE’ does not name a type
不能识别JS_EXPORT_PRIVATE和JS_EXPORTDATA。在不能识别的头文件里,加入下列宏定义:
#ifndef JS_EXPORT_PRIVATE
#define JS_EXPORT_PRIVATE WTF_IMPORT
#endif
#ifndef JS_EXPORTDATA
#define JS_EXPORTDATA JS_EXPORT_PRIVATE
#endif
所有需要添加的头文件列举如下:
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/runtime/JSCJSValue.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/yarr/YarrPattern.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/runtime/JSExportMacros.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/heap/Weak.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/API/JSStringRef.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/API/OpaqueJSString.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/parser/SourceCode.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/parser/SourceProvider.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/bytecode/Watchpoint.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/heap/MarkStack.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/heap/MachineStackMarker.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/heap/VTableSpectrum.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/heap/WriteBarrierSupport.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/runtime/SamplingCounter.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/debugger/Debugger.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/parser/SourceProviderCache.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/profiler/Profile.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/runtime/InitializeThreading.h
qt-everywhere-opensource-src-5.5.1/qtwebkit/Source/JavaScriptCore/runtime/JSLock.h
参考文献
[1] 在hisi上QT交叉编译过程(带webengine)
https://blog.csdn.net/heliangbin87/article/details/82499522
[2] 关于c语言中的program_invocation_short_name
https://www.cnblogs.com/vanwoos/p/6684170.html