1.在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/Qt4.8.6
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
2.copyQt库和编译好的应用程序; 从虚拟机ubuntu将Qt库copy到对应目录,我这里已经已通过nfs,挂载到/opt
~ # mount
/dev/root on / type ext4 (rw,relatime,data=ordered)
proc on /proc type proc (rw,nosuid,nodev,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
172.16.10.3:/home/chad/share_nfs on /opt type nfs (rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=172.16.10.3,mountvers=3,mountproto=tcp,local_lock=all,addr=172.16.10.3)
cp -rv /opt/Qt4.8.6/ /usr/local/
cp -v /opt//test3559 ~/
3.加载 profile 或者重启
source /etc/profile
4. 执行test3559
chmod 777 test3599
./test3559
报这个错误:
~ # ./test3559
./test3559: line 2: syntax error: unexpected ")"
./test3559: line 1: ELF: not found~
5.在ubuntu中查看test3559状态
5.1 file ./build-test3559-hi3559_desk-Debug/test3559
./build-test3559-hi3559_desk-Debug/test3559: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=7a1c4e7b8d85162c58bc0de69845e15f40834ffc, not stripped
可以看到系统架构不对,内核版本也不对!
5.2直接查看makefile 情况:
~/build-test3559-hi3559_desk-Release$ vi Makefile
#############################################################################
# Makefile for building: test3559
# Generated by qmake (2.01a) (Qt 4.8.6) on: Tue Apr 23 11:29:58 2019
# Project: ../test3559/test3559.pro
# Template: app
# Command: /usr/local/Qt4.8.6/bin/qmake -spec /usr/local/Qt4.8.6/mkspecs/qws/linux-hi3559-g++ -o Makefile ../test3559/test3559.pro
#############################################################################
####### Compiler, tools and options
CC = $(QCROSS_HI3559)-gcc
CXX = $(QCROSS_HI3559)-g++
$(warning "cc=$(CC)")
$(warning "cXX=$(CXX)")
DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/local/Qt4.8.6/mkspecs/qws/linux-hi3559-g++ -I../test3559 -I/usr/local/Qt4.8.6/include/QtCore -I/usr/local/Qt4.8.6/include/QtNetwork -I/usr/local/Qt4.8.6/include/QtGui -I/usr/local/Qt4.8.6/include -I. -I. -I../test3559 -I.
LINK = $(QCROSS_HI3559)-g++
增加
$(warning "cc=$(CC)")
$(warning "cXX=$(CXX)")
结果打印:
chad@ubuntu:~/build-test3559-hi3559_desk-Release$ make
Makefile:13: "cc=-gcc"
Makefile:14: "cXX=-g++"
/usr/local/Qt4.8.6/bin/uic ../test3559/testmainwindow.ui -o ui_testmainwindow.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8.6/mkspecs/qws/linux-hi3559-g++ -I../test3559 -I/usr/local/Qt4.8.6/include/QtCore -I/usr/local/Qt4.8.6/include/QtNetwork -I/usr/local/Qt4.8.6/include/QtGui -I/usr/local/Qt4.8.6/include -I. -I. -I../test3559 -I. -o main.o ../test3559/main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8.6/mkspecs/qws/linux-hi3559-g++ -I../test3559 -I/usr/local/Qt4.8.6/include/QtCore -I/usr/local/Qt4.8.6/include/QtNetwork -I/usr/local/Qt4.8.6/include/QtGui -I/usr/local/Qt4.8.6/include -I. -I. -I../test3559 -I. -o testmainwindow.o ../test3559/testmainwindow.cpp
/usr/local/Qt4.8.6/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8.6/mkspecs/qws/linux-hi3559-g++ -I../test3559 -I/usr/local/Qt4.8.6/include/QtCore -I/usr/local/Qt4.8.6/include/QtNetwork -I/usr/local/Qt4.8.6/include/QtGui -I/usr/local/Qt4.8.6/include -I. -I. -I../test3559 -I. ../test3559/testmainwindow.h -o moc_testmainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8.6/mkspecs/qws/linux-hi3559-g++ -I../test3559 -I/usr/local/Qt4.8.6/include/QtCore -I/usr/local/Qt4.8.6/include/QtNetwork -I/usr/local/Qt4.8.6/include/QtGui -I/usr/local/Qt4.8.6/include -I. -I. -I../test3559 -I. -o moc_testmainwindow.o moc_testmainwindow.cpp
g++ -Wl,-O1 -o test3559 main.o testmainwindow.o moc_testmainwindow.o -L/usr/local/Qt4.8.6/lib -lQtGui -L/usr/local/Qt4.8.6/lib -lQtNetwork -lQtCore -lpthread
尴尬了,hi3559的工具链没有传过来!
5.3 查询QCROSS_HI3559
原来是配置hi3559qt的时候,编译器没有传过来!
可能和?=应该关系,也许:=或者=,可以赋值传过来,准备先强制原值来实现,重新编译Qt,参照第一篇!
5.4 修改后重新编译Qt4.8.6,再编译test3559,可以看到
查看编译后的文件:
可以看到已经编译成arm版本的了! ^.^
6.将更新后的 /usr/local/Qt4.8.4 更新到hi3559开发板,test3559也更新
执行情况如下:
~ # ./test3559
[15:53:$s]: QWSSocket::connectToLocalFile could not connect:: No such file or directory
[15:53:$s]: QWSSocket::connectToLocalFile could not connect:: No such file or directory
[15:53:$s]: QWSSocket::connectToLocalFile could not connect:: No such file or directory
[15:53:$s]: QWSSocket::connectToLocalFile could not connect:: No such file or directory
[15:53:$s]: QWSSocket::connectToLocalFile could not connect:: No such file or directory
[15:53:$s]: QWSSocket::connectToLocalFile could not connect:: No such file or directory
[15:53:$s]: No Qt for Embedded Linux server appears to be running.
[15:53:$s]: If you want to run this program as a server,
[15:53:$s]: add the "-qws" command-line option.
[15:53:$s]: ~ # ./test3559 -qws
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
[15:53:$s]: QScreenLinuxFb::connect: No such file or directory
[15:53:$s]: Error opening framebuffer device /dev/fb0
说明已经可以在hi3559上运行了,另外需要hi3559将fb0打开!将在下一篇中更新~