Qt跨平台开发

摘要

Ubuntu16.04
交叉编译工具:arm-linux-gcc-4.3.2.tar.gz
Qt源码压缩包:qt-everywhere-opensource-src-4.7.1.tar.gz

开发环境准备篇

一、Ubuntu16.04需要安装的软件

安装 Ubuntu16.04 系统后,需要把站点更新为清华站点
具体的设置过程如下:
右上角小齿轮→System Settings→System→Software & updates
→Ubuntu Software→Download from 选择站点
→选择清华站点
→弹出验证→输入 root 账号密码
→替换为清华的下载点
→apt-get update 更新

1.1 安装和使用 SSH 软件(用来进Windows和Ubuntu系统之间文件传输)

  • apt-get install vim ssh” 安装 vim 编辑器以及 ssh 工具

1.2 /etc/init.d/ssh restart” 启动 ssh 服务

1.3 调整配置文件

  • “vim /etc/ssh/sshd_config” 打开配置文件
Ciphers   
aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blow fish-cbc,cast128-cbc
MACs
hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
KexAlgorithms
diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffiehellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

说明:KexAlgorithms可剪裁

 #Authentication: 
 LoginGraceTime 120
 #PermitRootLogin prohibit-password 
 PermitRootLogin yes 
 StrictModes yes

1.4 /etc/init.d/ssh restart”命令重启 ssh 服务 ;安装相关库

apt-get install lzop  // lzop是开源的压缩算法框架
apt-get install u-boot-tools 
apt-get install autoconf // 
apt-get install automake // 
apt-get install libtool  // 编译大型软件的过程中解决了库的依赖问题
apt-get install libstdc++6  // 
apt-get install lib32c-dev  //
apt-get install lib32stdc++6
apt-get install lib32z1
apt-get install lib32ncurses5

A、安装交叉编译器

root@ubuntu:~# sudo vim .bashrc

在这里插入图片描述

root@ubuntu:~# sudo vim .bashrc
root@ubuntu:~# source .bashrc
root@ubuntu:~# arm-none-linux-gnueabi-gcc -v

B、编译触摸

源码 tslib-1.4.tar.gz
在这里插入图片描述

C、安装交叉编译 QtE5.7 库

root@ubuntu:/home/qishuai/qt/qt_source# vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
root@ubuntu:/home/qishuai/qt/qt_source# ls
qt-everywhere-opensource-src-5.7.0  qt-everywhere-opensource-src-5.7.0.tar.gz  tslib  tslib-1.4.tar.gz
root@ubuntu:/home/qishuai/qt/qt_source# cd qt-everywhere-opensource-src-5.7.0
root@ubuntu:/home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0# vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
root@ubuntu:/home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0# ls
coin                LICENSE.GPLv2               qtactiveqt       qtdatavis3d         qtlocation       qtquickcontrols2  qtsvg              qtwebengine    README
configure           LICENSE.GPLv3               qtandroidextras  qtdeclarative       qtmacextras      qtscript          qttools            qtwebsockets
configure.bat       LICENSE.LGPLv21             qtbase           qtdoc               qtmultimedia     qtscxml           qttranslations     qtwebview
gnuwin32            LICENSE.LGPLv3              qtcanvas3d       qtgamepad           qt.pro           qtsensors         qtvirtualkeyboard  qtwinextras
LGPL_EXCEPTION.txt  LICENSE.PREVIEW.COMMERCIAL  qtcharts         qtgraphicaleffects  qtpurchasing     qtserialbus       qtwayland          qtx11extras
LICENSE.FDL         qt3d                        qtconnectivity   qtimageformats      qtquickcontrols  qtserialport      qtwebchannel       qtxmlpatterns
root@ubuntu:/home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0# vi autoconfigure.sh
root@ubuntu:/home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0# chmod 777 autoconfigure.sh
root@ubuntu:/home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0# ./autoconfigure.sh

make前编译

NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1.
Configure with '-qreal float' to create a build that is binary compatible with 5.1.

NOTE: -optimized-tools is not useful in -release mode.

Info: creating stash file /home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0/.qmake.stash
Info: creating super cache file /home/qishuai/qt/qt_source/qt-everywhere-opensource-src-5.7.0/.qmake.super

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /opt/qt5.7.0

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

二、根文件系统

1.配置busybox工具

  • 配置busybox的交叉编译工具 arm-none-linux-gnueabi-
  • 设置最终生成的二进制文件安装到system目录下
  • 编译busybox执行make命令后,开始编译Busybox命令
  • 编译完成后,用make install 安装二进制到…/system目录
  • 文件系统还需新建 dev etc lib mnt proc sys tmp var 文件夹
  • etc 目录下 创建eth0-setting文件和init.d文件夹、passwd文件、profile文件

IP=192.168.1.230
Mask=255.255.255.0
Gateway=192.168.1.1
DNS=192.168.1.1
MAC=08:90:90:90:90:90

  • 在init.d文件夹下建立ifconfig-eth0文件和rcS文件

  • etc目录下再建rc.d文件夹,在此目录下建立init.d文件夹,在init.d文件目录下建立netd文件

  • 拷贝编译器里面的库到lib目录

  • 在var目录下建立lib lock log run tmp

  • 解压打包工具:Linux_tools.tgz

执行:make_ext4fs -s -l 314572800 -a root -L Linux system.img system
生成根文件系统

三、交叉编译QT源码

1.在Ubuntu上编译Qt库

  • 新建文件夹,解压 qt- everywhere-opensource-src-5.7.0.tar.gz
  • 进入qt- everywhere-opensource-src-5.7.0文件夹,使用命令 vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
# 
#qmake configuration for building with arm-linux-gnueabi-g++
#
AKEFILE_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)

添加或修改qmake.conf文件。

  • 使用 vi autoconfigure.sh新建脚本, 执行脚本命令 ./autoconfigure.sh,在/opt文件夹下生成qt-5.7.0 ; 把 Qt 库安装到开发板的文件系统, 并生成镜像。
#!/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
  • 生成可以下载的system.img,需要工具 mkimage --> linux_tools.tgz
  • 新建linux+Qt文件夹,copy根文件系统
  • 编译生成的“qt5.7.0”文件和“tslib1.4”触摸文件到 …/root/opt目录下
  • 将字库文件“fonts”拷贝到“opt/qt5.7.0/lib/”目录下。 将“libstdc.tar.gz”拷贝到“./lib”解压, 并输入命令: ln -s libstdc++.so.6.0.19 libstdc++.so.6
  • 修改环境变量 vim etc/profile
  • 修改开机启动脚本vi etc/init.d/rcS, 注释掉 /bin/qt4 &, 并加上 /bin/qt5.7 &
  • 在linux+Qt文件目录下输入:

make_ext4fs -s -l 314572800 -a root -L linux system.img root

附录

1.解压命令
tar -xvf busybox-1.21.1.tar.bz2
2.内核编译配置命令
make menuconfig
3.文件创建命令
mkdir
4.创建文件命令
vi eth0-setting
5.文件权限修改
chmod 755
6.copy命令
lib# cp /user/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/* ./

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值