嵌入式QT5.5.1在freescale IMX6Q平台的编译安装

编译qt5.5.1步骤

1 去官网下载qt5.5.1,解压

vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf  修改
MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

##########  add  start  ##################
# note:下面的第二项根据CPU架构来设置,比如我这边是A9,
#  如果是A8要设置成armv5te,
#

QT_QPA_DEFAULT_PLATFORM = linux
QMAKE_CFLAGS_RELEASE   += -O2 -march=armv7-a
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
##########  add  end   ###################

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

###########modify start ######################
# note:下面是对编译器的配置,我这里的编译工具全部修改成arm-linux-*
##############################################

# modifications to g++.conf
QMAKE_CC                = arm-linux-gcc
QMAKE_CXX               = arm-linux-g++
QMAKE_LINK              = arm-linux-g++
QMAKE_LINK_SHLIB        = arm-linux-g++

# modifications to linux.conf
QMAKE_AR                = arm-linux-ar cqs
QMAKE_OBJCOPY           = arm-linux-objcopy
QMAKE_NM                = arm-linux-nm -P
QMAKE_STRIP             = arm-linux-strip
load(qt_config)
##############modify end #####################

2 配置QT

a  先安装libpng库
我的ubuntu版本是12.04,
libpng库下载地址:http://pan.baidu.com/s/1mhXdY9E    http://pan.baidu.com/s/1gfl1qEn
下载后dpkg   -i   *.deb安装即可

b  配置
./configure -v -prefix /home/liuhaobi/qt5.5.1_20170103/__install -release -make libs -xplatform linux-arm-gnueabi-g++ -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -no-opengl -no-sse2 -no-openssl -no-nis -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -no-iconv -dbus
出现一堆错误,暂时不管这些错误,可以先不管,有空再去一个个解决,PC上少库的缘故

3编译QT

make -j4

4 编译出现一系列错,下面对即将出现的错误逐一解决

(1) 执行make -j4后出现第一个错误

Cannot find libdbus-1 in your system to resolve symbol 'dbus_get_local_machine_id'.

解决办法:安装libdbus库

(2) dbus-1.2.30安装  

a 下载,解压dbus-1.2.30,下载地址:http://pan.baidu.com/s/1hs4wegs
b 配置dbus-1.2.30
./configure --host=arm-linux --prefix=/home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install CC=arm-linux-gcc --without-x
###注意:--prefix选项是dbus-1.2.30的安装路径,根据自己的情况设置
###本博主dbus-1.2.30安装路径:/home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install
c 编译dbus-1.2.30
make
提示错误
configure: error: Could not find expat.h, check config.log for failed attempts
原因:需要现安装 expat 。。。

(3) 安装expat

a 下载,解压expat,下载地址:http://pan.baidu.com/s/1o8oASdG
b 配置expat
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/home/liuhaobi/qt5.5.1_20170103/expect_lib/expat_install
###注意:--prefix选项是expat的安装路径
###本博主安装路径/home/liuhaobi/qt5.5.1_20170103/expect_lib/expat_install
c 编译安装expat
make 和 make install

(4) 再次配置dbus,编译,安装

CC=arm-linux-gcc ./configure CFLAGS=-I/home/liuhaobi/qt5.5.1_20170103/expect_lib/expat_install/include LDFLAGS=-L/home/liuhaobi/qt5.5.1_20170103/expect_lib/expat_install/lib --prefix=/home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install --host=arm-linux --enable-abstract-sockets

###注意:CFLAGS是expat的头文件路径,LDFLAGS是expat的库文件路径,--prefix是dbus-1.2.30的安装路径
make && make install

(5) 移植完 dbus 库后,将 /opt/EmbedRigol/install-dev/dbus-1.2.30/lib 文件夹下 libdbus-1.so 相关的文件拷贝到开发板/lib 文件夹下,博主拷贝了全部文件及文件夹

在qt/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf加入以下内容
QMAKE_INCDIR += /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install/include/dbus-1.0
QMAKE_INCDIR += /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install/lib/dbus-1.0/include
QMAKE_LIBDIR += /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install/lib

目前qmake.conf中内容为:
MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental

QMAKE_INCREMENTAL_STYLE = sublib

##########  add  start  ##################
# note:下面的第二项根据CPU架构来设置,比如我这边是A9,
#  如果是A8要设置成armv5te,
#
QT_QPA_DEFAULT_PLATFORM = linux
QMAKE_CFLAGS_RELEASE   += -O2 -march=armv7-a
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
##########  add  end   ###################

##########  add  start  ##################
# note:QMAKE_INCDIR、QMAKE_INCDIR、QMAKE_LIBDIR都是dbus的安装路径下
#   /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install是dbus的安装路径
#
QMAKE_INCDIR    += /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install/include/dbus-1.0
QMAKE_INCDIR    += /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install/lib/dbus-1.0/include
QMAKE_LIBDIR    += /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus_install/lib
##########  add  end   #################

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

###########  modify start ######################
# note:下面是对编译器的配置,我这里的编译工具全部修改成arm-linux-*
##############################################

# modifications to g++.conf
QMAKE_CC                = arm-linux-gcc
QMAKE_CXX               = arm-linux-g++
QMAKE_LINK              = arm-linux-g++
QMAKE_LINK_SHLIB        = arm-linux-g++

# modifications to linux.conf
QMAKE_AR                = arm-linux-ar cqs
QMAKE_OBJCOPY           = arm-linux-objcopy
QMAKE_NM                = arm-linux-nm -P
QMAKE_STRIP             = arm-linux-strip
load(qt_config)
##############  modify end #####################

(6)将之前修改好的qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf拷贝出来,删除编译过的qt源码,重新解压,重新配置
a 配置:
./configure -v -prefix /home/liuhaobi/qt5.5.1_20170103/__install -release -make libs -xplatform linux-arm-gnueabi-g++ -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -no-opengl -no-sse2 -no-openssl -no-nis -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -no-iconv -dbus
b 编译安装:make && make install
c 再次在将qt拷贝到开发板中,运行应用程序
./testqt5 -platform linuxfb
出错:
process 85: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open “/opt/EmbedRigol/install-dev/dbus-1.2.30/var/lib/dbus/machine-id”: No such file or directory

(8) 解决办法:在pc上执行下面语句:
mkdir /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus-1.2.30/var/lib/dbus/ -p
dbus-uuidgen > /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus-1.2.30/var/lib/dbus/machine-id
###dbus目录:/home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus-1.2.30
在开发板上执行:
mkdir /home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus-1.2.30/var/lib/dbus/ -p
将pc上生成的machine-id文件拷贝到开发板的/home/liuhaobi/qt5.5.1_20170103/expect_lib/dbus-1.2.30/var/lib/dbus/下

5 编译ts1.4

忽略,百度太多

6 开发板上给QT配置环境变量

#tslib环境变量配置
export TSLIBDIR=/home/tslib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event2

export TSLIB_CALIBFILE=$TSLIBDIR/etc/pointercal
export TSLIB_CONFFILE=$TSLIBDIR/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIBDIR/lib/ts
export PATH=/home/tslib/bin:$PATH
export LD_LIBRARY_PATH=/home/tslib/lib:$LD_LIBRARY_PATH

#QT环境变量配置
export QT_ROOT=/home/qt                          
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:$QT_ROOT/lib
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:/dev/input/event2             
export QML2_IMPORT_PATH=$QT_ROOT/qml

7在开发板上运行程序

./testqt5 -platform linuxfb

你可能感兴趣的:(QT)