zoukankan      html  css  js  c++  java
  • Linux编译移植Qt5的环境_Xillinx的ZYNQ平台

    Linux编译Qt环境

    2017年的十一假期,足不出户,一个人在教研室里面搞Qt的移植。我手里面有Samsung的CortexA8,Samsung的 CortexA53还有Ti的Sitara系列的AM3517的ARM,都成功的移植了Qt,然而在我接触ZYNQ这个平台的时候,偏偏搞的我三天的时间,无法移植,ZYNQ上面安装的是Linaro这个阉割版本的Ubuntu,怎么都不成功,一个问题,在我的PC机上编译完到Linaro上面运行的时候,没有反应,不启动也不报错。

    准备

    • 交叉编译环境(一定要找到适合你板子的交叉编译环境)

    你需要用嵌入式环境编译Qt和Qt所开发的程序。

    • Qte嵌入式源代码,文件的名字如同:qt-everywhere-opensource-src-5.7.0.tar.xz

    我的环境:

    PC 机: Ubuntu16.04 (64bit)

    Linaro交叉编译工具链 : (gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar.xz)
    Qt源码: qt-everywhere-opensource-src-5.7.0.tar.gz

    交叉编译环境配置

    其实也可以不进行配置,反正后面我们在编译器名称的时候都用绝对路径

    配置环境变量一共有好几种方法,交叉编译环境的方法就不说了:

    参考:http://www.linuxidc.com/Linux/2013-06/85902.htm

    编译tslib1.4

    对触摸屏信号的获取、校正、滤波处理,均采用开源的tslib,本文采用的tslib版本为最新的tslib1.4(可以从本文提供的链接中下载tslib1.4)。
    1.将下载好的tslib1.4拷贝到/home/lz/transplant目录下(可以根据自己的系统选择某一目录),然后执行解压缩命令

    tar -vxf tslib-1.4.tar.gz1
    

    切换到tslib目录:

    cd tslib
    

    安装交叉编译tslib必须的一些工具(可以先查看是否已安装,ubuntu16.04自带这些工具,可跳过)

    sudo apt-get install autoconf
    sudo apt-get install automake
    sudo apt-get install libtool
    

    2.利用脚本写编译过程
    在tslib文件夹下新建文件configTslib14.sh

    vi configTslib14.sh
    

    内容如下:

    #!/bin/sh
    make clean && make distclean
    echo "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache
    CC=/usr/local/arm/arm-2014.05/bin/arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --prefix=/opt/tslib1.4 --cache-file=arm-linux.cache
    make && make install
    

    然后运行configTslib14.sh

    ./configTslib14.sh
    

    执行结束后,我们查看一下是否安装成功,执行命令:

    ls /opt/tslib1.4
    

    如果出现bin,etc,include,lib这4个目录,如下图所示,说明交叉编译并安装tslib成功。
    这里写图片描述

    *交叉编译QT5.7.0

    将下载的qt-everywhere-opensource-src-5.7.0.tar.gz执行如下命令解压:

    tar -vxf qt-everywhere-opensource-src-5.7.0.tar.gz
    
    cd qt-everywhere-opensource-src-5.7.01
    

    创建架构信息:

    • 进入架构信息路径

    cd ./qtbase/mkspecs/

    • 创建两个文件

    touch qmake.config qplatformdefs.h

    • 修改qplatformdefs.h ,直接把下面这个粘贴上去,对一个问
    /****************************************************************************
    **
    ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
    ** Contact: http://www.qt-project.org/legal
    ** 
    **
    ** $QT_BEGIN_LICENSE:LGPL21$
    ** Commercial License Usage
    ** Licensees holding valid commercial Qt licenses may use this file in
    ** accordance with the commercial license agreement provided with the
    ** Software or, alternatively, in accordance with the terms contained in
    ** a written agreement between you and Digia. For licensing terms and
    ** conditions see http://qt.digia.com/licensing. For further information
    ** use the contact form at http://qt.digia.com/contact-us.
    **
    ** GNU Lesser General Public License Usage
    ** Alternatively, this file may be used under the terms of the GNU Lesser
    ** General Public License version 2.1 or version 3 as published by the Free
    ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
    ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
    ** following information to ensure the GNU Lesser General Public License
    ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
    ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    **
    ** In addition, as a special exception, Digia gives you certain additional
    ** rights. These rights are described in the Digia Qt LGPL Exception
    ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    **
    ** $QT_END_LICENSE$
    **
    ****************************************************************************/
    
    #include "../linux-g++/qplatformdefs.h"
    
    • 修改交叉编译架构用到的信息:
    gedit ./qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.config
    

    修改如下图所示:

    我在这里的时候,即便是配置了交叉编译环境,还是提示arm-linux-gnueabi-gcc找不到,而我单拿出来在命令行上面 arm-linux-gnueabi-gcc -v 的时候还能显示出来,我换了四种方法配置交叉编译环境,重启N次还是不见效,所以我在qmake.config文件上做了手脚,使用绝对路径进行配置,没想到编译通过了,所以我建议在qmake.config文件上使用绝对路径。

    #
    # 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                = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-gcc
    QMAKE_CXX               = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-g++
    QMAKE_LINK              = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-g++
    QMAKE_LINK_SHLIB        = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-g++
    
    # modifications to linux.conf
    QMAKE_AR                = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-ar cqs
    QMAKE_OBJCOPY           = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-objcopy
    QMAKE_NM                = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-nm -P
    QMAKE_STRIP             = /home/delvis/opt/gcc-linaro-arm-linux-guneabihf/bin/arm-none-linux-gnueabi-strip
    load(qt_config)
    

    创建一个脚本文件,用于生成Makefile,执行命令

    gedit autoConfigure.sh
    

    输入下面内容并保存:

    ./configure -release -opensource -xplatform linux-arm-gnueabi-g++ -prefix /opt/qt5-arm -no-c++11 -no-opengl
    

    其中-prefix /opt/qt-5.7.0代表我们编译完QT5.4.1后要安装地址;-tslib代表QT对触摸板的支持,-I 和 -L后面分别为为第一步编译tslib的include和lib的安装目录。
    执行命令:

    chmod 777 qt.configure.sh
    ./autoConfigure.sh
    

    上述命令自动生成Makefile文件。
    执行命令启动编译:

    make -j8
    

    编译大概20分钟左右(I5-7500 的CPU)。
    编译结束后,执行安装命令:

    sudo make install
    

    我们切换到目标目录下看看是否安装成功:

    cd /opt/qt-5.7.0
    ls
    

    如图所示:

    将/opt/qt-5.7.0和/opt/tslib1.4 拷贝到开发板的文件系统中对应的目录中。

  • 相关阅读:
    探寻京东云核心竞争力的源泉
    在线公开课 | 教你如何自行搭建一个威胁感知大脑?
    推迟学习系统调用
    linux中未实现的系统调用
    man(2) V
    man(2) W
    图像叠加
    man(2) readv writev
    qt 视频播放
    ffmpeg参数
  • 原文地址:https://www.cnblogs.com/sigma0/p/7799156.html
Copyright © 2011-2022 走看看