运行 qt-opensource-linux-x86_64-4.5.2.run
创建工程测试是否qtcreat
报错 1
:-1: error: cannot find -lGL
错误1 解决办法
原因:Qt5.0 以上的版本默认将OpenGL加入了工程,但是在机器上没有安装OpenGL,所以只需要在机器系统安装OpenGL即可
sudo apt-get install libgl1-mesa-dev
Tslib:是一个开源的程序,能够为触摸屏驱动获得的采样提供诸如滤波、去抖、校准等功能,通常作为触摸屏驱动的适配层,为上层的应用提供了一个统一的接口。
//解压tslib
tar -xvf tslib-1.4.tar.gz
创建编译脚本
vim build_tslib.sh
sudo chmod 777 build_tslib.sh
#!/bin/sh
./autogen-clean.sh
./autogen.sh //报错 错误2
# 设置目标机型,缓冲,安装路径 指定交叉编译工具与输出路径
./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/li/linux/install_soft/tslib
make -j6 //编译过程中报错
make install
安装成功后验证 install_dir/tslib
ls /home/li/linux/install_soft/tslib
--------------------------------------------------------------
bin etc include lib
--------------------------------------------------------------
错误2 解决办法
报错 not found autoconf
sudo apt-get install autoconf automake libtool
拷贝tslib到根文件系统中
sudo cp -rf tslib/ /home/li/linux/nfs/rootfs/
vim /home/li/linux/share/rootfs/etc/profile
echo'-----------------------export tslib env------------------------------'
export T_ROOT=/tslib
export LD_LIBRARY_PATH=/tslib/lib:$LD_LIBRARY_PATH
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_PLUGINDIR=$T_ROOT/lib/ts
export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf
export POINTERCAL_FILE=/etc/pointercal
export TSLIB_CALIBFILE=/etc/pointercal
导入环境变量 并设置ts目录路径
export T_ROOT=/tslib
导入环境变量 并设置ts库文件路径
export LD_LIBRARY_PATH=/tslib/lib:$LD_LIBRARY_PATH
//导入环境变量 并设置ts显示设备为fb0 帧缓存
export TSLIB_FBDEVICE=/dev/fb0
//导入环境变量 并设置ts触摸输入设备,可以鼠标,触摸屏幕,这里使用的鼠标
export TSLIB_TSDEVICE=/dev/input/event0
//创建安装路径
mkdir /home/li/linux/install_soft/arm_qt
//解压
tar -xvf qt-everywhere-opensource-src-5.6.0.tar.gz
创建编译脚本 需要指定 qt源码目录 tslib目录
vi autoconfigure.sh
#!/bin/sh
./configure \
-prefix /home/li/linux/install_soft/arm-qt \
-confirm-license \
-opensource \
-shared \
-release \
-make libs \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-qt-sql-sqlite \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-no-opengl \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-dbus \
-no-xcb \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-no-fontconfig \
-nomake examples -nomake tools -nomake tests -no-iconv \
-tslib \
-I /home/li/linux/install_soft/tslib/include \
-L /home/li/linux/install_soft/tslib/lib
exit
需要注意 qt 安装路径 以及上一步安装的tslib路径
指定交叉编译工具及 tslib 的路径
vim qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
# qmake configuration for building with arm-linux-gnueabi-g++
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
+ QT_QPA_DEFAULT_PLATFORM = linuxfb
+ QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
+ QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
- QMAKE_CC = arm-linux-gnueabi-gcc
- QMAKE_CXX = arm-linux-gnueabi-g++
- QMAKE_LINK = arm-linux-gnueabi-g++
- QMAKE_LINK_SHLIB = arm-linux-gnueabi-g++
+ QMAKE_CC = arm-linux-gnueabihf-gcc
+ QMAKE_CXX = arm-linux-gnueabihf-g++
+ QMAKE_LINK = arm-linux-gnueabihf-g++
+ QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++
# modifications to linux.conf
- QMAKE_AR = arm-linux-gnueabi-ar cqs
- QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy
- QMAKE_NM = arm-linux-gnueabi-nm -P
- QMAKE_STRIP = arm-linux-gnueabi-strip
+ QMAKE_AR = arm-linux-gnueabihf-ar cqs
+ QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
+ QMAKE_NM = arm-linux-gnueabihf-nm -P
+ QMAKE_STRIP = arm-linux-gnueabihf-strip
+ QMAKE_INCDIR += /home/li/linux/install_soft/tslib/include
+ QMAKE_LIBDIR += /home/li/linux/install_soft/tslib/lib
load(qt_config)
//配置脚本给权限
sudo chmod u+x autoconfigure.sh
//配置
./autoconfigure.sh
--------------------------------------------------------------
Qt is now configured for building. Just run 'make'.
...
--------------------------------------------------------------
//编译
make -j6
make install
ls /home/li/linux/linux_qt/install_dir/qt5.6/arm-qt
--------------------------------------------------------------
bin doc include lib mkspecs plugins qml translations
--------------------------------------------------------------
cd bin
./qmake -v
--------------------------------------------------------------
QMake version 3.0
Using Qt version 5.6.0 in /home/li/linux/linux_qt/install_dir/qt5.6/arm-qt/lib
--------------------------------------------------------------
sudo cp -rf /home/li/linux/install_soft/arm-qt /home/li/linux/nfs/rootfs
设置环境变量
sudo vim /home/li/linux/nfs/rootfs/etc/profile
echo'-----------------------export qt env------------------------------'
export QTEDIR=/arm-qt
export LD_LIBRARY_PATH=/arm-qt/lib:$LD_LIBRARY_PATH
export QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/input/event0
export QT_QPA_FONTDIR=$QTEDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1280x720:mmSize=1280x720:offset=0x0:tty=/dev/ttymxc0
当支持触摸屏时需要配置:export QT_QPA_GENERIC_PLUGINS="tslib:/dev/input/event0
当需要支持鼠标时需要配置:export QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/input/event0
当需要同时支持触摸屏和鼠标时则需要配置成:export QT_QPA_GENERIC_PLUGINS=“tslib:/dev/input/event0 MouseMan:/dev/input/mouse0”
libiconv qt解决中文乱码用于编码转换使用的库
//创建安装路径
mkdir /home/li/linux/install_soft/libiconv
//解压
tar -xvf libiconv-1.14.tar_2.gz
//创建脚本
vim build_libiconv.sh
sudo chmod 777 build_libiconv.sh
#!/bin/sh
make clean
//配置
./configure --host=arm-linux --prefix=/home/li/linux/install_soft/libiconv CC=arm-linux-gnueabihf-gcc
make
//安装libiconv到目标文件夹
make install
验证libicon
objdump -a /lib/preloadable_libiconv.so
--------------------------------------------------------------
preloadable_libiconv.so: 文件格式 elf32-little
--------------------------------------------------------------
移植preloadable_libiconv.so到板卡中
cd /home/li/linux/install_soft/libiconv/lib
sudo cp preloadable_libiconv.so /home/li/linux/nfs/rootfs/lib
设置环境变量
vim /home/li/linux/share/rootfs/etc/profile
export LD_PRELOAD=/lib/preloadable_libiconv.so
添加字库文件到根文件系统中
需要将DroidSansFallback.ttf 中文字库到复制到文件系统中
sudo mkdir lib/fonts
cp DroidSansFallback.ttf /home/li/linux/nfs/rootfs/arm-qt/lib/fonts
DroidSansFallback.ttf 必须存在export QT_QPA_FONTDIR=$QTEDIR/lib/fonts 所指向的文件夹
环境变量
echo'-----------------------export qt env------------------------------'
export LD_PRELOAD=/lib/preloadable_libiconv.so
export T_ROOT=/tslib
export LD_LIBRARY_PATH=/tslib/lib:$LD_LIBRARY_PATH
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event2
export TSLIB_PLUGINDIR=$T_ROOT/lib/ts
export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf
export POINTERCAL_FILE=/etc/pointercal
export TSLIB_CALIBFILE=/etc/pointercal
export QTEDIR=/qt5.6
export LD_LIBRARY_PATH=/qt5.6/lib:$LD_LIBRARY_PATH
export QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/input/event2
export QT_QPA_FONTDIR=$QTEDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1280x720:mmSize=1280x720:off set=0x0:tty=/dev/ttymxc0