此博文是对工作的记录。
参考博文https://blog.csdn.net/yfkyfk521/article/details/89446969,感谢作者。
系统:Ubuntu12.0.4
交叉编译工具:aarch64-himix100-linux-
Qt版本:qt4.8.6
1.安装交叉编译工具链
交叉编译工具会在海思SDK包里,按照文档配置安装交叉编译工具。安装完成可以找到aarch64-himix100-linux-命令
2.交叉编译Qt
1)下载Qt源码,http://download.qt.io/archive/qt/
2)解压源码文件
tar -xzvf /home/ls/qt-everywhere-opensource-src-4.8.6.tar.gz
3)交叉编译
创建linux-hi3559-g++文件夹,复制qt-everywhere-opensource-src-4.8.6/mkspecs/qws/linux-arm-g++中文件到新文件夹中
mkdir linux-hi3559-g++
cp –r linux-arm-g++/ linux-hi3559-g++
对linux-hi3559-g++中的qmake.conf进行修改
#
# qmake configuration for building with arm-linux-g++
#
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)
# modifications to g++.conf
QMAKE_CC = aarch64-himix100-linux-gcc
QMAKE_CXX = aarch64-himix100-linux-g++
QMAKE_LINK = aarch64-himix100-linux-g++
QMAKE_LINK_SHLIB = aarch64-himix100-linux-g++
# modifications to linux.conf
QMAKE_AR = aarch64-himix100-linux-ar cqs
QMAKE_OBJCOPY = aarch64-himix100-linux-objcopy
QMAKE_STRIP = aarch64-himix100-linux-strip
load(qt_config)
创建一个文件夹,存放编译完成生成的文件
mkdir /home/ls/Qt_hi3559a
返回源码目录,配置编译模块
./configure --prefix=/home/ls/Qt_hi3559a -opensource -confirm-license -qt-sql-sqlite -qt-gfx-linuxfb -plugin-sql-sqlit -no-qt3support -no-phonon -no-svg -no-webkit -no-javascript-jit -no-script -no-scripttools -no-declarative -no-declarative-debug -qt-zlib -no-gif -qt-libtiff -qt-libpng -no-libmng -qt-libjpeg -no-rpath -no-pch -no-3dnow -no-avx -no-neon -no-openssl -no-nis -no-cups -no-dbus -embedded arm -platform linux-g++ -xplatform qws/linux-hi3559-g++ -little-endian -qt-freetype -no-opengl -no-glib -nomake demos -nomake examples -nomake docs -nomake tools
其中: --prefix=/usr/local/Qt4.8.6 为交叉编译目标安装目录
-embedded arm: 表示将编译针对arm平台的embedded版本;
-xplatform qws/linux-hi3559-g++指定编译器及平台配置信息
此时可能出现错误如下
(1)
make[1]: 正在进入目录 `/home/duliqun/qt-everywhere-opensource-src-4.8.5/src/corelib'
g++ -c -include .pch/release-shared-emb-arm/QtCore -pipe -I/opt/tslib-1.0/include -fno-exceptions -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_QLOCALE_USES_FCVT -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE
-DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DELF_INTERPRETER=\"\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -I../../mkspecs/linux-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm
-Iglobal -I../3rdparty/zlib -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm -o .obj/release-shared-emb-arm/qabstractanimation.o animation/qabstractanimation.cpp
../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h: Assembler messages:
../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h:131: Error: no such instruction: `swpb %cl,%dl,[%ebp]'
../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h:131: Error: no such instruction: `swpb %dl,%sil,[%ebp]'
可能是arm 交叉环境有问题,如果配置好了一般reconfigure下就ok.如果总是有问题,可以修改qatomic_armv5.h,将汇编用c
code写可以避过这个错误。
vi /home/ls/qt-everywhere-opensource-src-4.8.6/src/corelib/arch/qatomic_armv5.h
inline char q_atomic_swp(volatile char *ptr, char newval)
{ register char ret;
/*asm volatile("swpb %0,%2,[%3]"
: "=&r"(ret), "=m" (*ptr)
: "r"(newval), "r"(ptr)
: "cc", "memory");*/
ret=*ptr;
*ptr=newval;
return ret; }
(2)
configure可以通过,make失败出现
Makefile:7037: recipe for target '.obj/release-shared-emb-arm/qabstractanimation.o' failed
make[1]: *** [.obj/release-shared-emb-arm/qabstractanimation.o] Error 1
make[1]: Leaving directory '/home/chad/qt-everywhere-opensource-src-4.8.6/src/corelib'
Makefile:196: recipe for target 'sub-corelib-make_default-ordered' failed
修改 /src/corelib/io/io.pri 99行添加编译器
# vi ./src/corelib/io/io.pri
修改前
修改后
(3)
编译出现这个错误:
修改 itemviews.cpp
~/qt-everywhere-opensource-src-4.8.6$ vi src/plugins/accessible/widgets/itemviews.cpp +396
//view()->selectionModel()->select(index,
// QItemSelectionModel::Columns & QItemSelectionModel::Deselect );
view()->selectionModel()->select(index,
QItemSelectionModel::SelectionFlags(
QItemSelectionModel::Columns & QItemSelectionModel::Deselect ));
配置完成此时可以
make
make install
3.安装Qt Creator,增加编译套件
通过qtcreator,tools->options->Build&Run,配置qt versions
配置编译器
配置gdb
cmake 默认不变即可
增加kits
4.修改Hi3559a开发版上环境变量
在hi3559上,修改profile文件
vi /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shells
#
#
set_path_before()
{
[ -d $1 ] && PATH="$1:$PATH"
}
export QT_INSTALL_PATH=/usr/local/Qt_Hi3559a
export QT_QWS_FONTDIR=${QT_INSTALL_PATH}/lib/fonts
export QT_PLUGIN_PATH=${QT_INSTALL_PATH}/lib/plugins
export QT_QWS_DISPLAY=linuxFB:/dev/fb0
PATH="/usr/bin:/usr/sbin:/bin:/sbin:${QT_INSTALL_PATH}"
set_path_before /usr/local/sbin
set_path_before /usr/local/bin
LD_LIBRARY_PATH="/usr/local/lib:/usr/lib:${QT_INSTALL_PATH}/lib:${LD_LIBRARY_PATH}"
export PATH
export LD_LIBRARY_PATH
# ANSI COLORS
CRE="^M^[[K"
NORMAL="^[[0;39m"
RED="^[[1;31m"
GREEN="^[[1;32m"
YELLOW="^[[1;33m"
BLUE="^[[1;34m"
MAGENTA="^[[1;35m"
CYAN="^[[1;36m"
WHITE="^[[1;37m"
umask 077
echo "${GREEN}Welcome to HiLinux.${NORMAL}"
echo 1 >/proc/sys/kernel/randomize_va_space
echo 8192 >/proc/sys/vm/min_free_kbytes
将虚拟机上编译完成的Qt文件复制到到/usr/local/下,
加载 profile 或者重启
source /etc/profile
5.修改运行Sample_hifb,这里另开博文说明
6.拷贝虚拟机上完成构建的工程文件test
chmod 777 test
./test -qws