基于itop4412或者x210的QT5.7移植

一、移植环境

Ubuntu16.04+itop4412或者x210

二、tslib移植和测试

1、tslib移植(交叉编译工具链arm-2009q3)

(1)源码下载qt社区有,或者百度链接:https://pan.baidu.com/s/1JQyHXmUALtlL14V57-U03g

(2)解压                tar -zxvf tslib-1.4.tar.gz

(3)配置

cd tslib

./autogen.sh

echo "ac_cv_func_malloc_0_nonnull=yes">arm-linux.cache

./configure --prefix=/opt/tslib1.4 --host=arm-linux --cache-file=arm-linux.cache

(4)编译和安装

扫描二维码关注公众号,回复: 4028730 查看本文章

make

make install

2、问题及解决:

如果./autogen.sh时报错:./autogen.sh: 4: autoreconf: not found,是因为系统中没有安装autoconf工具,解决方法:先让ubuntu能上网,然后执行:sudo apt-get install autoconf automake libtool

3、导出环境变量

export TSLIB_ROOT=/opt/tslib1.4

export TSLIB_TSDEVICE=/dev/input/event2

export TSLIB_CALIBFILE=/etc/pointercal

export TSLIB_TSEVENTTYPE=input

export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf

export TSLIB_PLUGINDIR=$TSLIB_ROOT//lib/ts

export TSLIB_CONSOLEDEVICE=none

export TSLIB_FBDEVICE=/dev/fb0

export QWS_MOUSE_PROTO=tslib:/dev/input/event2

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib

 

注1:这里的修改是针对开发板的,不是针对PC的,切记!

注2:对上文的几个变量进行一下说明。注意其中部分变量需根据你自己开发板的实际情况修改:

TSLIB_ROOT                      // 你在开发板上实际存放的路径。

TSLIB_TSDEVICE                  // 触摸屏设备文件名,在/dev/input/目录下查看。

QWS_MOUSE_PROTO                 // 同TSLIB_TSDEVICE

TSLIB_CALIBFILE                 // 校准的数据文件,由ts_calibrate校准程序生成。

TSLIB_CONFFILE                  // 配置文件名。

TSLIB_PLUGINDIR                 // 插件目录。

TSLIB_CONSOLEDEVICE             // 控制台设备文件名。

TSLIB_FBDEVICE                  // 设备名。

 

4、运行和测试

(1)/opt/tslib1.4/ts_calibrate # 进行触摸屏的校准测试

     /opt/tslib1.4/ts_test # 进行触摸屏的绘图测试

(2)错误1:No raw modules loaded.

ts_config: No such file or directory

解决:在etc/ts.conf中打开module raw input这行的注释就行了。

 

  错误2:selected device is not a touchscreen I understand

  

解决:引自韦东山博客:https://www.cnblogs.com/weidongshan/p/8336427.html

将tslib库中c和H文件加入Source Insight,跟踪源码发现,在 input-raw.c文件中有这么一段代码:

 

static int check_fd(struct tslib_input *i)

 

{

struct tsdev *ts = i->module.dev;

int version;

u_int32_t bit;

u_int64_t absbit;

if (! ((ioctl(ts->fd, EVIOCGVERSION, &version) >= 0) &&

(version == EV_VERSION) &&

(ioctl(ts->fd, EVIOCGBIT(0, sizeof(bit) * 8), &bit) >= 0) &&

(bit & (1 << EV_ABS)) &&

(ioctl(ts->fd, EVIOCGBIT(EV_ABS, sizeof(absbit) * 8), &absbit) >= 0) &&

(absbit & (1 << ABS_X)) &&

(absbit & (1 << ABS_Y)) && (absbit & (1 << ABS_PRESSURE)))) {

fprintf(stderr, "selected device is not a touchscreen I understand\n");

return -1;

}

if (bit & (1 << EV_SYN))

i->using_syn = 1;

return 0;

}

其中关键的是version == EV_VERSION这个判断语句,如果这俩不等,那么就会打印出selected device is not a touchscreen I understand。

tslib中的input版本号是在交叉编译的时候指定的,赋值给version,而EV_VERSION是在内核中定义,笔者做tslib时,用的2.6.39内核,这个EV_VERSION定义在linux源码的include/linux/input.h中,值是0x010001,而tslib中的version是和交叉编译器相同,查看编译器,在 /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include/linux/input.h中,值是0x010000,这俩明显不相等,当然不会满足version == EV_VERSION,所以导致错误。

所以,以下提供两种解决方法:

1.将内核源代码里的include/linux/input.h中的

#define EV_VERSION 0x010001

改为:

#define EV_VERSION 0x010000

2.将arm交叉编译工具中的头文件库中的

linux/input.h中的

#define EV_VERSION 0x010000

改为

#define EV_VERSION 0x010001

然后再编译tslib库

 

三、在Ubuntu16.04安装qtcreator

1、自己百度教程

2、安装后建一个helloworld工程,编译,可能出现有关GPL的错误

解决qtcreator编译错误

sudo apt-get install build-essential

sudo apt-get install libqt4-dev

3、编译arm版本的可执行程序

进到helloworld工程目录下,执行“/opt/qt5.7.0/bin/qmake”命令,生成一个Makefile,然后make

 

四、Qt5.7源码编译安装

源码qt-everywhere-opensource-src-5.7.0在qt社区有链接下载,怕你找不到:https://download.qt.io/archive/qt/5.7/5.7.0/single/

交叉编译工具链(arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2)

记得修改导出的工具链的路径

1、在“qt-everywhere-opensource-src-5.7.0”目录下,使用“ vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf ”命令,打开 qmake.conf,修改成如下所示

 

# #

qmake configuration for building with arm-linux-gnueabi-g++

#

MAKEFILE_GENERATOR = UNIX

CONFIG += incremental

QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linux #eglfs

QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a

QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a

include(../common/linux.conf)

include(../common/gcc-base-unix.conf)include(../common/g++-unix.conf)

# modifications to g++.conf

QMAKE_CC = arm-none-linux-gnueabi-gcc

QMAKE_CXX = arm-none-linux-gnueabi-g++

QMAKE_LINK = arm-none-linux-gnueabi-g++

QMAKE_LINK_SHLIB = arm-none-linux-gnueabi-g++

# modifications to linux.conf

QMAKE_AR = arm-none-linux-gnueabi-ar cqs

QMAKE_OBJCOPY = arm-none-linux-gnueabi-objcopy

QMAKE_NM = arm-none-linux-gnueabi-nm -P

QMAKE_STRIP = arm-none-linux-gnueabi-strip

load(qt_config)

 

2、使用“vi autoconfigure.sh”命令,新建“autoconfigure.sh”脚本,脚本内容如下所示,

保存后chmod 777 autoconfigure.sh

 

#!/bin/sh

./configure \

-v \

-prefix /opt/qt5.7.0 \

-release \

-opensource \

-make libs \

-xplatform linux-arm-gnueabi-g++ \

-optimized-qmake \

-pch \

-qt-sql-sqlite \

-qt-libjpeg \

-qt-zlib \

-no-opengl \

-skip qt3d \

-skip qtcanvas3d \

-skip qtpurchasing \

-no-sse2 \

-no-openssl \

-no-nis \

-no-cups \

-no-glib \

-no-iconv \

-nomake examples \

-nomake tools \

-skip qtvirtualkeyboard \

-I/opt/tslib1.4/include \

-L/opt/tslib1.4/lib

exit

 

3、“./autoconfigure.sh”执行脚本,会有版本认证,输入yes

 

4、make编译后make install安装

 

5、(资源在前面百度链接)将字库文件“fonts”拷贝到“opt/qt5.7.0/lib/”目录下。将“libstdc.tar.gz”拷贝到

“./lib”(开发板根目录下的lib)解压(tar xvf libstdc.tar.gz),并输入命令:ln -s libstdc++.so.6.0.19 libstdc++.so.6

 

6、修改环境变量“vim etc/profile”,添加如下所示。

 

export QT_ROOT=/opt/qt5.7.0

export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:$QT_ROOT/lib:$LD_LIBRARY_PATH

export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins

export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0

export QT_QPA_FONTDIR=$QT_ROOT/lib/fonts

export QT_QPA_GENERIC_PLUGINS=tslib

 

7、测试

若出现错误:Couldnt load module pthres

 ts_config()什么鬼东东。。。

首先检查自己的环境变量的设置,上网搜一下,看有没有解决办法,

我的解决办法:在profile文件中添加以下一句,然后“source /etc/profile”

export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so

 

 

猜你喜欢

转载自blog.csdn.net/DGY1223/article/details/83932800