赖大师告诉你:如何把 Qt 5.2.1 编译到zynq

赖大师告诉你:如何把 Qt 5.2.1 编译到zynq
这个是官方的方法:
Update for Qt 5.3.2: https://blog.idv-tech.com/2014/10/15/building-and-configuring-qt5-tslib-and-evtest-for-arm-xilinx-zynq/.

这是一个为Zynq构建最新Qt 5.2.1并将其用于PetaLinux 2013.10项目的小技巧。我使用64位Ubuntu 18.04作为主机,Xilinx Vivado 2018.2和ZedBoard
“版本D’作为目标。如果这个方法适合你,尤其是如果你在其他板上使用它,请让我知道,这样我就可以推动Qt Zynq支持的变化

  1. 下载并解压: Qt everywhere 的源代码到你的home/Download 文件夹
    wget http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz
    tar -zxvf qt-everywhere-opensource-src-5.2.1.tar.gz
  2. Qt5还不支持Zynq设备,所以我们需要添加它。您可以下载并提取准备好的文件(linux-arm-xilinx-zynq-g++.tar.gz)(linux-arm-xilinx-zynq-g++.tar.gz) 复制到“qt-everywhere-opensource-src-5.2.1/qtbase/mkspecs/devices/linux-arm-xilinx-zynq-g++”文件夹。 或者你自己创建:
    在’qt-everywhere-opensource-src-5.2.1/qtbase/mkspecs/devices’ 创建这个新的文件夹 ‘linux-arm-xilinx-zynq-g++’.
    在 ‘linux-arm-xilinx-zynq-g++’ 创建’qmake.conf’ 文件:

qmake configuration for linux-g++ using arm-xilinx-g++ compiler

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental gdb_dwarf_index
QMAKE_INCREMENTAL_STYLE = sublib
 
include(…/…/common/linux.conf)
include(…/…/common/gcc-base-unix.conf)
include(…/…/common/g+±unix.conf)
 
load(device_config)
 
QT_QPA_DEFAULT_PLATFORM = linuxfb

modifications to g++.conf

QMAKE_CC                = C R O S S C O M P I L E g c c Q M A K E C X X                             = {CROSS_COMPILE}gcc QMAKE_CXX               = CROSSCOMPILEgccQMAKECXX              ={CROSS_COMPILE}g++
QMAKE_LINK              = Q M A K E C X X Q M A K E L I N K S H L I B               = {QMAKE_CXX} QMAKE_LINK_SHLIB        = QMAKECXXQMAKELINKSHLIB       ={QMAKE_CXX}

modifications to linux.conf

QMAKE_AR                = C R O S S C O M P I L E a r c q s Q M A K E O B J C O P Y                     = {CROSS_COMPILE}ar cqs QMAKE_OBJCOPY           = CROSSCOMPILEarcqsQMAKEOBJCOPY          ={CROSS_COMPILE}objcopy
QMAKE_NM                = C R O S S C O M P I L E n m − P Q M A K E S T R I P                         = {CROSS_COMPILE}nm -P QMAKE_STRIP             = CROSSCOMPILEnmPQMAKESTRIP            ={CROSS_COMPILE}strip
 
QMAKE_CFLAGS           += -I [ Q T S Y S R O O T ] / i n c l u d e − D Z Y N Q Q M A K E C X X F L A G S                 + = − W n o − p s a b i − I [QT_SYSROOT]/include -DZYNQ QMAKE_CXXFLAGS         += -Wno-psabi -I [QTSYSROOT]/includeDZYNQQMAKECXXFLAGS        +=WnopsabiI[QT_SYSROOT]/include -DZYNQ
QMAKE_LFLAGS           += -L [ Q T S Y S R O O T ] / l i b   Q M A K E C F L A G S                     + = − m a r c h = a r m v 7 − a − m c p u = c o r t e x − a 9 − m t u n e = c o r t e x − a 9 − m f p u = n e o n − p i p e − f o m i t − f r a m e − p o i n t e r Q M A K E C X X F L A G S                 + = [QT_SYSROOT]/lib   QMAKE_CFLAGS           += -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -pipe -fomit-frame-pointer QMAKE_CXXFLAGS         += [QTSYSROOT]/lib QMAKECFLAGS          +=march=armv7amcpu=cortexa9mtune=cortexa9mfpu=neonpipefomitframepointerQMAKECXXFLAGS        +=QMAKE_CFLAGS
 
deviceSanityCheckCompiler()
load(qt_config)
和这个文件 ‘qplatformdefs.h’ file:
/****************************************************************************
**
** Copyright © 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** Q T B E G I N L I C E N S E : L G P L QT_BEGIN_LICENSE:LGPL QTBEGINLICENSE:LGPL
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** Q T E N D L I C E N S E QT_END_LICENSE QTENDLICENSE
**
****************************************************************************/
 
#include “…/…/linux-g++/qplatformdefs.h”

3. QT_QPA_DEFAULT_PLATFORM变量设置为Linux Framebuffer,如果您的硬件设计支持其他东西,您可能需要更改它。或者你也可以通过QT_QPA_PLATFORM 环境来控制它。变量,并将默认值保留为最简单的“linuxfb”。您可能还想在此处修改CFLAGS和CxFlags。

4. 设置CROSS_COMPILE 变量和source Xilinx tools 设置:
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
source /opt/Xilinx/Vivado/2013.4/settings64.sh
5. 现在我们可以运行Qt configure实用程序,下面是我的构建脚本中的配置。请注意,我禁用了OpenGL ES支持,因为我的硬件还没有,但您可能会禁用,所以您可能希望包括egl支持.
./configure -prefix /opt/Qt/5.2.1
    -device linux-arm-xilinx-zynq-g++
    -device-option CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    -release
    -no-qml-debug
    -reduce-relocations
    -qt-zlib
    -qt-libpng
    -qt-libjpeg
    -qt-freetype
    -qt-harfbuzz
    -qt-pcre
    -no-xcb
    -qt-xkbcommon
    -no-opengl
    -no-eglfs
    -no-kms
    -confirm-license
    -opensource
    -no-icu
    -no-pch
    -verbose

6.Configure将首先生成“qmake”,并为所有组件生成“'Makefiles”。详细检查输出,并验证其是否与配置匹配。以下是我的例子:

Configure summary
 
Building on:   linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for:  devices/linux-arm-xilinx-zynq-g++ (arm, CPU features: neon)
Platform notes:
 
            - Also available for Linux: linux-kcc linux-icc linux-cxx
         
qmake vars … styles += mac fusion windows DEFINES += QT_NO_MTDEV
DEFINES += QT_NO_LIBUDEV DEFINES += QT_NO_XCB sql-drivers =  sql-plugins =  sqlite qmake switches …
 
Build options:
  Configuration … accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples
 concurrent cross_compile evdev eventfd freetype full-config getaddrinfo getifaddrs harfbuzz iconv inotify
 ipv6ifname large-config largefile linuxfb medium-config minimal-config mremap neon nis no-pkg-config pcre
 png posix_fallocate qpa qpa reduce_exports reduce_relocations release rpath shared small-config xkbcommon-qt zlib
  Build parts … libs examples
  Mode … release
  Using C++11 … yes
  Using PCH … no
  Target compiler supports:
    iWMMXt/Neon … no/yes
 
Qt modules and options:
  Qt D-Bus … no
  Qt Concurrent … yes
  Qt GUI … yes
  Qt Widgets … yes
  JavaScriptCore JIT … yes (To be decided by JavaScriptCore)
  QML debugging … no
  Use system proxies … no
 
Support enabled for:
  Accessibility … yes
  ALSA … no
  CUPS … no
  FontConfig … no
  FreeType … qt
  HarfBuzz … qt
  Iconv … yes
  ICU … no
  Image formats:
    GIF … yes (plugin, using bundled copy)
    JPEG … yes (plugin, using bundled copy)
    PNG … yes (in QtGui, using bundled copy)
  Glib … no
  GTK theme … no
  Large File … yes
  mtdev … no
  Networking:
    getaddrinfo … yes
    getifaddrs … yes
    IPv6 ifname … yes
    OpenSSL … no
  NIS … yes
  OpenGL … no
  OpenVG … no
  PCRE … yes (bundled copy)
  pkg-config … no
  PulseAudio … no
  QPA backends:
    DirectFB … no
    EGLFS … no
    KMS … no
    LinuxFB … yes
    XCB … no
  Session management … yes
  SQL drivers:
    DB2 … no
    InterBase … no
    MySQL … no
    OCI … no
    ODBC … no
    PostgreSQL … no
    SQLite 2 … no
    SQLite … yes (plugin, using bundled copy)
    TDS … no
  udev … no
  xkbcommon … yes (bundled copy)
  zlib … yes (bundled copy)
 
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.
Info: creating cache file /home/d9/Projects/qt5_build_test/qt-everywhere-opensource-src-5.2.1/qtbase/.qmake.cache
 
Qt is now configured for building. Just run ‘gmake’.
Once everything is built, you must run ‘gmake install’.
Qt will be installed into /opt/Qt/5.2.1
 
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

  1. 构建并安装Qt。它将安装在配置期间设置为前缀的目录中。
    cd qt-everywhere-opensource-src-5.2.1/qtbase/
    gmake & gmake install
    8.现在,让我们向PetaLinux项目添加Qt库和几个Qt示例二进制文件。转到PetaLinux项目目录,使用“libs”模板创建Qt组件。
    petalinux-create -t libs -n qt-5.2.1 --enable
    9.我们不需要模板创建的文件,所以删除它们。
    cd components/libs/qt-5.2.1/
    rm libqt*
    10.将预构建的Qt库文件复制到“lib”子目录,将Qt字体和插件目录也复制到“lib”子目录,并将几个Qt示例复制到“bin”子目录:
    cp -Pr /opt/Qt/5.2.1/lib .
    cp -Pr /opt/Qt/5.2.1/plugins/ ./lib/
    mkdir bin
    cp /opt/Qt/5.2.1/examples/widgets/painting/pathstroke/pathstroke bin/pathstroke
    cp /opt/Qt/5.2.1/examples/widgets/mainwindows/mainwindow/mainwindow bin/mainwindow
    11.我们还必须在目标rootfs上设置一些环境变量,所以让我们创建’profile.qt-5.2.1’文件。最后一个是“tslib”,所以如果你不使用它,你可以删除它。此外,根据您的设置,您可能需要更改此设置或在此处添加其他变量。
    export QT_PLUGIN_PATH=/usr/lib/plugins
    export QT_QPA_FONTDIR=/usr/lib/fonts
    export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
    export QT_QPA_PLATFORM=linuxfb
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0

12.现在我们必须修改我们的PetaLinux组件Makefile。我们没有要构建的内容,但需要将Qt5库文件安装到目标rootfs。
ifndef PETALINUX
$(error “Error: PETALINUX environment variable not set. Try to source the settings.sh file”)
endif
 
include libs.common.mk
 
LIB=libqt_5_2_1
 
all: build install
 
.PHONY: build
build:
 
install:
    #Install libraries and fonts to the rootfs.
 
    mkdir -p $(TARGETDIR)/usr/lib
    USER=your_user_name
    GROUP=your_user_group
    rsync -rav ./bin/* $(TARGETDIR)/usr/bin/
    rsync -rav ./lib/* $(TARGETDIR)/usr/lib/
 
    #Install the script to ensure the font directory is properly specified.
    mkdir -p $(TARGETDIR)/etc/profile.d
    cp profile.qt-5.2.1 $(TARGETDIR)/etc/profile.d/profile.qt-5.2.1
 
clean:

13.最后的配置步骤是将“LiBSTDC + 6”包含到目标ROTFS中,因为QT是C++库并依赖于它。
petalinux-config -c rootfs
· Then go to ‘Filesystem Packages’ -> ‘Base’ -> ‘External-xilinx-toolchain’ -> Enable ‘libstdc++6’.
· · 就这样。重建Linux项目,传输映像。ub文件到SD卡。Qt5库将增加大约20M的图像大小,因此它可能不适合保留空间,您可能需要调整适当的u-boot变量(loadaddr、netstart…)。启动后,我们可以运行“pathstroke”和“mainwindow”Qt示例应用程序。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值