Ubuntu 14.04系统下安装和编译QT 5.9.2库桌面版和IMX6嵌入式版全过程

最近要搞一个嵌入式项目,在I.MX6平台上基于linux系统使用QT做界面开发,于是就研究了一下如何对QT 5.9.2版本的代码进行下载和编译。同时,因为嵌入式平台上涉及到是否启动OpenGL,还得分成两个版本来编译。再加上PC端,总共就有3个版本了,如下:

  • x11桌面OpenGL版,将其命名为qt-5.9.2-x11-opengl版本,用于在PC端模拟调试带OpenGL的程序。
  • arm嵌入式常规版,将其命名为qt-5.9.2-arm-normal版本,用于在I.MX6平台上运行不带OpenGL的程序。
  • arm嵌入式OpenGL版,将其命名为qt-5.9.2-arm-opengl版本,用于在I.MX6平台上运行带OpenGL的程序。

下面就开始详细介绍搭建、安装、编译等全过程的记录。

一、准备工作

1、开发环境介绍

  • 主机系统:win10(64位);
  • 虚拟工具:Virtualbox 5.2.0;
  • 虚拟系统:Ubuntu 14.04(64位);

2、下载QT源码

直接去官网(http://download.qt.io/archive/qt/)下载QT的源码即可。

由于某些历史原因,我这里下载的是5.9.2版本。建议大家也同样使用这个版本,毕竟我自己已经亲自验证过了。如果您使用新的版本,可能会遇到一些其他的问题。

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里需要注意的是,我们要下载的是源码压缩包,而不是现成编译好的可执行文件。所以,请进入“single”目录进行下载。我选择的是后缀名为tar.xz的文件(因为它比较小),解压得分两步走,先解开xz,然后再解开tar,命令如下:

xz -d qt-everywhere-src-5.9.2.tar.xz
tar -xvf qt-everywhere-src-5.9.2.tar

3、安装编译工具

请确保系统中已安装gcc、g++和OpenGL。可使用以下命令进行测试并验证它们的具体版本:

I、gcc工具

gcc --version

如果没有响应,或者提示gcc没有安装,则可以使用下述命令进行安装:

sudo apt-get  install  build-essential

安装完成之后,同样使用上述命令查看一下gcc的版本进行确认。

II、g++工具

g++ --version

如果没有响应,或者提示g++没有安装,则可以使用下述命令进行安装:

sudo apt-get install g++

安装完成之后,同样使用上述命令查看一下g++的版本进行确认。

III、OpenGL

glxinfo | grep OpenGL

如果提示“程序“glxinfo”尚未安装”,则可以使用下述命令进行安装:

sudo apt-get install mesa-utils

如果提示OpenGL找不到或者没有安装的话,则可使用下述命令安装(具体的详细过程可参见我的另外一篇博客:如何在Ubuntu 14.04下安装OpenGL开发环境)。

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libgl1-mesa-dev
sudo apt-get install libglu1-mesa-dev
sudo apt-get install libegl1-mesa-dev
sudo apt-get install freeglut3-dev

安装完成之后,同样使用上述命令查看一下OpenGL的版本进行确认。

4、搭建目录环境

根据QT官方的说法,建议大家不要在QT源码的目录下直接进行编译,这样会污染源码所在的目录,无法达到多个版本共存编译的效果。可以在QT源码所在的同级目录下,新建一个临时用的编译目录,只为存放编译脚本和编译所产生的临时文件。如下:

leon@Ubuntu:~/tempuse$ ll
总用量 20
drwxrwxr-x  4 leon leon 4096  810 11:10 ./
drwxr-xr-x 30 leon leon 4096  810 11:07 ../
drwxrwxr-x 43 leon leon 4096 104  2017 qt-everywhere-opensource-src-5.9.2/

leon@Ubuntu:~/tempuse$ mkdir qt-5.9.2-x11-opengl qt-5.9.2-arm-normal qt-5.9.2-arm-opengl

leon@Ubuntu:~/tempuse$ ll
总用量 32
drwxrwxr-x  7 leon leon 4096  810 11:13 ./
drwxr-xr-x 30 leon leon 4096  810 11:07 ../
drwxrwxr-x  2 leon leon 4096  810 11:13 qt-5.9.2-arm-normal/
drwxrwxr-x  2 leon leon 4096  810 11:13 qt-5.9.2-arm-opengl/
drwxrwxr-x  2 leon leon 4096  810 11:13 qt-5.9.2-x11-opengl/
drwxrwxr-x 43 leon leon 4096 104  2017 qt-everywhere-opensource-src-5.9.2/

于是,可以分别在qt-5.9.2-x11-opengl qt-5.9.2-arm-normal qt-5.9.2-arm-opengl这3个目录下进行不同版本的代码编译,而不会影响到源码所在的目录。

5、目标文件系统

由于最终编译出来的程序是要运行在I.MX6的嵌入式系统中,因此在编译的过程中要引入目标文件系统。我这里将该文件系统(fsl-image-gui-imx6qsabresd)解压放在/opt目录下。请记住这个目录,后面会用的到。

leon@Ubuntu:~$ cd /opt
leon@Ubuntu:/opt$ ll
总用量 32
drwxr-xr-x  8 root root 4096  810 13:39 ./
drwxr-xr-x 23 root root 4096 1011  2017 ../
drwxr-xr-x  4 leon leon 4096 1011  2017 FriendlyARM/
drwxr-xr-x 19 leon leon 4096 1114  2017 fsl-image-gui-imx6qsabresd/
drwxr-xr-x  9 root root 4096 1011  2017 VBoxGuestAdditions-5.0.20/
drwxr-xr-x  6 root root 4096  69  2017 wps-office_10.1.0.5707~a21_x86_64/

二、x11桌面OpenGL版

1、创建配置脚本

进入qt-arm目录,新建config.sh文件,输入:

#!/bin/sh

./../qt-everywhere-opensource-src-5.9.2/configure \
-verbose \
-opensource \
-release \
-shared \
-confirm-license \
-make libs \
-no-feature-cursor \
-no-qml-debug \
-no-use-gold-linker \
-no-iconv \
-prefix /opt/qt-5.9.2-x11-opengl

这里“-prefix /opt/qt-5.9.2-x11-opengl“是用于指定编译之后库文件所安装的位置,你可以按照你自己的规划和要求来更改,但是其他的指令不建议更改。

为config.sh文件增加可运行属性,并运行之。大约1-2分钟之后,结束,提示配置成功:

Configure summary:

Build type: linux-g++ (x86_64, CPU features: mmx sse sse2)
Configuration: sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2 compile_examples enable_new_dtags f16c largefile precompile_header shared rpath release c++11 concurrent dbus no-qml-debug reduce_exports reduce_relocations stl
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C++ standard ..................... C++11
  Using ccache ........................... no
  Using gold linker ...................... no
  Using new DTAGS ........................ yes
  Using precompiled headers .............. yes
  Using LTCG ............................. no
  Target compiler supports:
    SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
    AVX .................................. AVX AVX2 F16C
    AVX512 ............................... <none>
  Build parts ............................ libs
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... no
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... yes
  QML debugging .......................... no
  udev ................................... no
  Using system zlib ...................... yes
Qt Core:
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... no
  iconv .................................. no
  ICU .................................... no
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  Using system PCRE2 ..................... no
Qt Network:
  getaddrinfo() .......................... yes
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  OpenSSL ................................ no
    Qt directly linked to OpenSSL ........ no
  SCTP ................................... no
  Use system proxies ..................... yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ no
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
  Fontconfig ............................. no
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... no
    PNG .................................. yes
      Using system libpng ................ no
  EGL .................................... yes
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... yes
    OpenGL ES 2.0 ........................ no
    OpenGL ES 3.0 ........................ no
    OpenGL ES 3.1 ........................ no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon-evdev ........................ no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS EGLDevice ...................... no
    EGLFS GBM ............................ no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGL on X11 ........................... yes
  LinuxFB ................................ yes
  VNC .................................... yes
  Mir client ............................. no
  X11:
    Using system-provided XCB libraries .. no
    EGL on X11 ........................... yes
    Xinput2 .............................. no
    XCB XKB .............................. yes
    XLib ................................. yes
    XCB render ........................... yes
    XCB GLX .............................. yes
    XCB Xlib ............................. yes
    Using system-provided xkbcommon ...... no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt PrintSupport:
  CUPS ................................... no
Qt Sql:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
QtXmlPatterns:
  XML schema support ..................... yes
Qt QML:
  QML interpreter ........................ yes
  QML network support .................... yes
Qt Quick:
  Direct3D 12 ............................ no
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Gamepad:
  SDL2 ................................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Output Qt3D Job traces ................. no
  Output Qt3D GL traces .................. no
Qt 3D GeometryLoaders:
  Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
Qt Sensors:
  sensorfw ............................... no
Qt Quick Controls 2:
  Styles ................................. Default Material Universal
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
Qt Positioning:
  Gypsy GPS Daemon ....................... no
  WinRT Geolocation API .................. no
Qt Location:
  Geoservice plugins:
    OpenStreetMap ........................ yes
    HERE ................................. yes
    Esri ................................. yes
    Mapbox ............................... yes
    MapboxGL ............................. no
    Itemsoverlay ......................... yes
Qt Multimedia:
  ALSA ................................... no
  GStreamer 1.0 .......................... no
  GStreamer 0.10 ......................... no
  Video for Linux ........................ yes
  OpenAL ................................. no
  PulseAudio ............................. no
  Resource Policy (libresourceqt5) ....... no
  Windows Audio Services ................. no
  DirectShow ............................. no
  Windows Media Foundation ............... no
Qt WebEngine:
  Embedded build ......................... no
  Pepper Plugins ......................... yes
  Printing and PDF ....................... yes
  Proprietary Codecs ..................... no
  Spellchecker ........................... yes
  WebRTC ................................. yes
  Using system ninja ..................... no
  ALSA ................................... no
  PulseAudio ............................. no
  System libraries:
    re2 .................................. no
    ICU .................................. no
    libwebp and libwebpdemux ............. no
    Opus ................................. no
    ffmpeg ............................... no

Note: Also available for Linux: linux-clang linux-icc

Note: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing.

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/opt/qt-5.9.2-x11-opengl'.

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

2、编译和安装

输入下述命令开始编译。由于源码内容较多,编译时间会很长,以我的电脑i3-4160 3.6GHz处理器+4G内存的配置,编译了差不多40分钟。

make -j4

编译完成后,输入下述命令便可直接安装到之前预设的目录下:

sudo make install

三、arm嵌入式常规版

1、修改qmake文件

修改qt源码目录下的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

IMX6_CFLAGS = -march=armv7-a -mfpu=neon -DLINUX=1
IMX6_CFLAGS_RELEASE = -O2 $$IMX6_CFLAGS
QMAKE_CFLAGS_DEBUG += $$IMX6_CFLAGS
QMAKE_CXXFLAGS_DEBUG += $$IMX6_CFLAGS
QMAKE_CFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE
QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE

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

POKY_PATH = /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi
ROOTFS_PATH = /opt/fsl-image-gui-imx6qsabresd

# modifications to g++.conf
QMAKE_CC = $$POKY_PATH/arm-poky-linux-gnueabi-gcc -mfloat-abi=hard
QMAKE_CXX = $$POKY_PATH/arm-poky-linux-gnueabi-g++ -mfloat-abi=hard
QMAKE_LINK = $$POKY_PATH/arm-poky-linux-gnueabi-g++ -mfloat-abi=hard
QMAKE_LINK_SHLIB = $$POKY_PATH/arm-poky-linux-gnueabi-g++ -mfloat-abi=hard

# modifications to linux.conf
QMAKE_AR = $$POKY_PATH/arm-poky-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = $$POKY_PATH/arm-poky-linux-gnueabi-objcopy
QMAKE_NM = $$POKY_PATH/arm-poky-linux-gnueabi-nm -P
QMAKE_STRIP = $$POKY_PATH/arm-poky-linux-gnueabi-strip

QMAKE_INCDIR += $$ROOTFS_PATH/usr/include
QMAKE_LIBDIR += $$ROOTFS_PATH/usr/lib

load(qt_config)

2、创建配置脚本

进入qt-arm目录,新建config.sh文件,输入:

#!/bin/sh

./../qt-everywhere-opensource-src-5.9.2/configure \
-verbose \
-opensource \
-release \
-shared \
-confirm-license \
-linuxfb \
-make libs \
-no-feature-cursor \
-no-qml-debug \
-no-use-gold-linker \
-no-iconv \
-no-opengl \
-xplatform linux-arm-gnueabi-g++ \
-prefix /opt/qt-5.9.2-arm-normal \
-I/opt/fsl-image-gui-imx6qsabresd/usr/include \
-L/opt/fsl-image-gui-imx6qsabresd/usr/lib

这里“-prefix /opt/qt-5.9.2-x11-normal“是用于指定编译之后库文件所安装的位置,你可以按照你自己的规划和要求来更改,后面两句话则是用于指定I.MX6文件系统所在的目录位置,你也可以根据你自己的情况修改。但是其他的指令不建议更改。

为config.sh文件增加可运行属性,并运行之。大约1-2分钟之后,结束,提示配置成功:

Configure summary:

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-arm-gnueabi-g++ (arm, CPU features: neon)
Configuration: cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus no-pkg-config no-qml-debug reduce_exports stl
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C++ standard ..................... C++14
  Using ccache ........................... no
  Using gold linker ...................... no
  Using new DTAGS ........................ yes
  Using precompiled headers .............. yes
  Using LTCG ............................. no
  Target compiler supports:
    NEON ................................. yes
  Build parts ............................ libs
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... no
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... no
  QML debugging .......................... no
  udev ................................... no
  Using system zlib ...................... no
Qt Core:
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... no
  iconv .................................. no
  ICU .................................... no
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  Using system PCRE2 ..................... no
Qt Network:
  getaddrinfo() .......................... yes
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  OpenSSL ................................ no
    Qt directly linked to OpenSSL ........ no
  SCTP ................................... no
  Use system proxies ..................... yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ no
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
  Fontconfig ............................. no
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... no
    PNG .................................. yes
      Using system libpng ................ no
  EGL .................................... no
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ no
    OpenGL ES 3.0 ........................ no
    OpenGL ES 3.1 ........................ no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon-evdev ........................ no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. no
  LinuxFB ................................ yes
  VNC .................................... yes
  Mir client ............................. no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt PrintSupport:
  CUPS ................................... no
Qt Sql:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
QtXmlPatterns:
  XML schema support ..................... yes
Qt QML:
  QML interpreter ........................ yes
  QML network support .................... yes
Qt Quick:
  Direct3D 12 ............................ no
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Gamepad:
  SDL2 ................................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Output Qt3D Job traces ................. no
  Output Qt3D GL traces .................. no
Qt 3D GeometryLoaders:
  Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
Qt Sensors:
  sensorfw ............................... no
Qt Quick Controls 2:
  Styles ................................. Default Material Universal
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
Qt Positioning:
  Gypsy GPS Daemon ....................... no
  WinRT Geolocation API .................. no
Qt Location:
  Geoservice plugins:
    OpenStreetMap ........................ yes
    HERE ................................. yes
    Esri ................................. yes
    Mapbox ............................... yes
    MapboxGL ............................. no
    Itemsoverlay ......................... yes
Qt Multimedia:
  ALSA ................................... no
  GStreamer 1.0 .......................... no
  GStreamer 0.10 ......................... no
  Video for Linux ........................ yes
  OpenAL ................................. no
  PulseAudio ............................. no
  Resource Policy (libresourceqt5) ....... no
  Windows Audio Services ................. no
  DirectShow ............................. no
  Windows Media Foundation ............... no
Qt WebEngine:
  Embedded build ......................... yes
  Pepper Plugins ......................... no
  Printing and PDF ....................... no
  Proprietary Codecs ..................... no
  Spellchecker ........................... yes
  WebRTC ................................. no
  Using system ninja ..................... no
  ALSA ................................... no
  PulseAudio ............................. no
  System libraries:
    re2 .................................. no
    ICU .................................. no
    libwebp and libwebpdemux ............. no
    Opus ................................. no
    ffmpeg ............................... no

Note: Also available for Linux: linux-clang linux-icc

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

WARNING: Cross compiling without sysroot. Disabling pkg-config

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/opt/qt-5.9.2-arm-normal'.

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

3、编译和安装

输入下述命令开始编译。由于源码内容较多,编译时间会很长,以我的电脑i3-4160 3.6GHz处理器+4G内存的配置,编译了差不多50分钟。

make -j4

编译完成后,输入下述命令便可直接安装到之前预设的目录下:

sudo make install

四、arm嵌入式OpenGL版

1、修改qmake文件

修改qt源码目录下的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

IMX6_CFLAGS = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
IMX6_CFLAGS_RELEASE = -O2 $$IMX6_CFLAGS
QMAKE_CFLAGS_DEBUG += $$IMX6_CFLAGS
QMAKE_CXXFLAGS_DEBUG += $$IMX6_CFLAGS
QMAKE_CFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE
QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE

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

POKY_PATH = /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi
ROOTFS_PATH = /opt/fsl-image-gui-imx6qsabresd

# modifications to g++.conf
QMAKE_CC = $$POKY_PATH/arm-poky-linux-gnueabi-gcc -mfloat-abi=hard
QMAKE_CXX = $$POKY_PATH/arm-poky-linux-gnueabi-g++ -mfloat-abi=hard
QMAKE_LINK = $$POKY_PATH/arm-poky-linux-gnueabi-g++ -mfloat-abi=hard
QMAKE_LINK_SHLIB = $$POKY_PATH/arm-poky-linux-gnueabi-g++ -mfloat-abi=hard

# modifications to linux.conf
QMAKE_AR = $$POKY_PATH/arm-poky-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = $$POKY_PATH/arm-poky-linux-gnueabi-objcopy
QMAKE_NM = $$POKY_PATH/arm-poky-linux-gnueabi-nm -P
QMAKE_STRIP = $$POKY_PATH/arm-poky-linux-gnueabi-strip

QMAKE_INCDIR += $$ROOTFS_PATH/usr/include
QMAKE_LIBDIR += $$ROOTFS_PATH/usr/lib

QMAKE_LIBS_EGL += -lEGL -lGAL
QMAKE_LIBS_OPENGL_ES1 += -lGLESv1_CM -lEGL -lGAL
QMAKE_LIBS_OPENGL_ES1CL += -lGLES_CL -lEGL -lGAL
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL -lVSC
QMAKE_LIBS_OPENVG += -lOpenVG -lEGL -lGAL -lVSC

load(qt_config)

2、创建配置脚本

进入qt-arm目录,新建config.sh文件,输入:

#!/bin/sh

./../qt-everywhere-opensource-src-5.9.2/configure \
-verbose \
-opensource \
-release \
-shared \
-confirm-license \
-eglfs \
-linuxfb \
-openvg \
-make libs \
-no-feature-cursor \
-no-qml-debug \
-no-use-gold-linker \
-no-iconv \
-xplatform linux-arm-gnueabi-g++ \
-prefix /opt/qt-5.9.2-arm-opengl \
-I/opt/fsl-image-gui-imx6qsabresd/usr/include \
-L/opt/fsl-image-gui-imx6qsabresd/usr/lib

这里“-prefix /opt/qt-5.9.2-x11-normal“是用于指定编译之后库文件所安装的位置,你可以按照你自己的规划和要求来更改,后面两句话则是用于指定I.MX6文件系统所在的目录位置,你也可以根据你自己的情况修改。但是其他的指令不建议更改。

为config.sh文件增加可运行属性,并运行之。大约1-2分钟之后,结束,提示配置成功:

Configure summary:

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-arm-gnueabi-g++ (arm, CPU features: neon)
Configuration: cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus no-pkg-config no-qml-debug reduce_exports stl
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C++ standard ..................... C++14
  Using ccache ........................... no
  Using gold linker ...................... no
  Using new DTAGS ........................ yes
  Using precompiled headers .............. yes
  Using LTCG ............................. no
  Target compiler supports:
    NEON ................................. yes
  Build parts ............................ libs
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... no
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... no
  QML debugging .......................... no
  udev ................................... no
  Using system zlib ...................... no
Qt Core:
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... no
  iconv .................................. no
  ICU .................................... no
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  Using system PCRE2 ..................... no
Qt Network:
  getaddrinfo() .......................... yes
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  OpenSSL ................................ no
    Qt directly linked to OpenSSL ........ no
  SCTP ................................... no
  Use system proxies ..................... yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ no
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
  Fontconfig ............................. no
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... no
    PNG .................................. yes
      Using system libpng ................ no
  EGL .................................... yes
  OpenVG ................................. yes
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon-evdev ........................ no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS i.Mx6 .......................... yes
    EGLFS i.Mx6 Wayland .................. no
    EGLFS EGLDevice ...................... no
    EGLFS GBM ............................ no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGL on X11 ........................... no
  LinuxFB ................................ yes
  VNC .................................... yes
  Mir client ............................. no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt PrintSupport:
  CUPS ................................... no
Qt Sql:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
QtXmlPatterns:
  XML schema support ..................... yes
Qt QML:
  QML interpreter ........................ yes
  QML network support .................... yes
Qt Quick:
  Direct3D 12 ............................ no
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Gamepad:
  SDL2 ................................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Output Qt3D Job traces ................. no
  Output Qt3D GL traces .................. no
Qt 3D GeometryLoaders:
  Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
Qt Sensors:
  sensorfw ............................... no
Qt Quick Controls 2:
  Styles ................................. Default Material Universal
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
Qt Positioning:
  Gypsy GPS Daemon ....................... no
  WinRT Geolocation API .................. no
Qt Location:
  Geoservice plugins:
    OpenStreetMap ........................ yes
    HERE ................................. yes
    Esri ................................. yes
    Mapbox ............................... yes
    MapboxGL ............................. yes
    Itemsoverlay ......................... yes
Qt Multimedia:
  ALSA ................................... no
  GStreamer 1.0 .......................... no
  GStreamer 0.10 ......................... no
  Video for Linux ........................ yes
  OpenAL ................................. no
  PulseAudio ............................. no
  Resource Policy (libresourceqt5) ....... no
  Windows Audio Services ................. no
  DirectShow ............................. no
  Windows Media Foundation ............... no
Qt WebEngine:
  Embedded build ......................... yes
  Pepper Plugins ......................... no
  Printing and PDF ....................... no
  Proprietary Codecs ..................... no
  Spellchecker ........................... yes
  WebRTC ................................. no
  Using system ninja ..................... no
  ALSA ................................... no
  PulseAudio ............................. no
  System libraries:
    re2 .................................. no
    ICU .................................. no
    libwebp and libwebpdemux ............. no
    Opus ................................. no
    ffmpeg ............................... no

Note: Also available for Linux: linux-clang linux-icc

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

WARNING: Cross compiling without sysroot. Disabling pkg-config

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/opt/qt-5.9.2-arm-opengl'.

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

3、编译和安装

输入下述命令开始编译。由于源码内容较多,编译时间会很长,以我的电脑i3-4160 3.6GHz处理器+4G内存的配置,编译了差不多80分钟。

make -j4

编译完成后,输入下述命令便可直接安装到之前预设的目录下:

sudo make install

至此,3个版本的QT库全部编译和安装完成,分别位于opt目录下的指定位置。接下去就是安装QTCreator,然后在其中配置好相关的套件环境即可,在此不做记录,待下文分解。

猜你喜欢

转载自blog.csdn.net/LEON1741/article/details/81560704