QT下载地址:
http://download.qt.io/archive/qt/
1.编译tslib(touch screen lib)
准备工作:确保以下工具安装完成
sudo apt-get install autoconf automake libtool
1.解压
tar xf tslib-1.4.tar.gz
cd tslib
2.生成configure
./autogen.sh
3.配置(成功生成Makefile)
./configure --prefix=/usr/local/tslib/ --host=arm-linux ac_cv_func_malloc_0_nonnull=yes
4.make
5.sudo make install
6.确认成功
cd /usr/local/tslib/bin
执行以下命令:
file ts_calibrate
ts_calibrate: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
注:
_open_missing_mode ();错误解决
vim tests/ts_calibrate.c
搜索 O_CREAT
if ((calfile = getenv("TSLIB_CALIBFILE")) != NULL) {
cal_fd = open (calfile, O_CREAT | O_RDWR,0777);
} else {
cal_fd = open ("/etc/pointercal", O_CREAT | O_RDWR,0777);
}
给open函数加上第三个参数0777
--------------------------------------------------------
2.编译QT库
1.解压最新版的交叉编译器(4.8.3)
tar xvf arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
编译器路径:
/home/csgec/software/arm-2014.05/bin
2.解压Qt源码包
tar xvf qt-everywhere-opensource-src-5.6.0.tar.gz
cd qt-everywhere-opensource-src-5.6.0/
3.删除3d模块
rm qt3d/ qtcanvas3d/ qtweb* -rf
4.修改编译器
vim qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
QMAKE_INCDIR += /usr/local/tslib/include
QMAKE_LIBDIR += /usr/local/tslib/lib
QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
# modifications to g++.conf
QMAKE_CC = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-gcc
QMAKE_CXX = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-g++
QMAKE_LINK = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-g++
QMAKE_LINK_SHLIB = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-objcopy
QMAKE_NM = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-nm -P
QMAKE_STRIP = /home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-strip
load(qt_config)
5.配置参数
./configure -release -opensource -xplatform linux-arm-gnueabi-g++ -prefix /usr/local/qtlib5.6.0 -silent -tslib -qt-sql-sqlite -no-opengl -no-dbus -no-iconv -nomake examples -nomake tools -nomake tests
6.make
7.sudo make install
最后显示:
make[2]: Entering directory `/home/csgec/software/qt-everywhere-opensource-src-5.6.0/qtdoc/doc‘
make[2]: Nothing to be done for `install‘.
make[2]: Leaving directory `/home/csgec/software/qt-everywhere-opensource-src-5.6.0/qtdoc/doc‘
make[1]: Leaving directory `/home/csgec/software/qt-everywhere-opensource-src-5.6.0/qtdoc‘
8.打包库和插件
cd /usr/local/qtlib5.6.0
sudo mkdir QtDir
sudo cp lib/ plugins/ QtDir/ -rf
sudo tar zcf QtDir5.6.0.tar.gz QtDir/
生成QtDir5.6.0.tar.gz,复制到tftp目录
cp QtDir5.6.0.tar.gz ~/tftp/
9.把上一步生成的压缩包下载到开发板
在开发板上运行以下命令
tftp -gr QtDir5.6.0.tar.gz 192.168.1.158
解压此压缩包
tar xvf QtDir5.6.0.tar.gz
10.把触屏库打包下载到开发板
cd /usr/local/tslib
sudo tar zcvf tslib.tar.gz lib/
cp tslib.tar.gz ~/tftp/
在开发板上运行以下命令
tftp -gr tslib.tar.gz 192.168.1.158
解压此压缩包
tar xf tslib.tar.gz
修改下解压后的目录名,把它放到QtDir目录下
mv lib/ tslib
mv tslib QtDir
11.配置开发板运行环境
vi qtconf.sh
#!bin/sh
export QtHome=/home/ldh/QtDir#注意你的QTDir放在哪个地址你就写哪个地址我放在的是/home/ldh下
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QtHome/lib
#平台
export QT_QPA_PLATFORM_PLUGIN=$QtHome/plugins/
export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
#触屏
export QT_PLUGIN_PATH=$QtHome/plugins/
export QT_QPA_GENERIC_PLUGINS=tslib
export LD_PRELOAD=$QtHome/tslib/libts.so
#字体
export QT_QPA_FONTDIR=$QtHome/lib/fonts
运行以下命令使上面的配置生效
source qtconf.sh
执行以下命令测试配置是否成功
echo $QtHome
正常会显示以下信息
/home/ldh/QtDir
12.qtcreator配置
1.打开 tools->options 选择Build&Run
2.增加Compilers(编译器)
点击Add选择GCC
然后点击Browse选择g++
/home/csgec/software/arm-2014.05/bin/arm-none-linux-gnueabi-g++
选择完成点Apply
3.增加Qt版本
选择Qt Versions
点击Add
选择/usr/local/qtlib5.6.0/bin/qmake
选择完成点击Apply
4.增加工具包
选择Kits
点击Add
修改Complier为第2步设置的
修改Qt version为第3步设置的
Name改为Qt5.6.0-ARM
完成后点击Apply and OK
5.编译工程时要注意选择刚刚添加的工具包Qt5.6.0-ARM
同时选择release
最后rebuild