AnsweredAssumed Answered

IMX6DL 运行qt程序提示This plugin does not support createPlatformOpenGLContext!  Aborted

Question asked by 维 朱 on Jan 23, 2019
Latest reply on Jan 25, 2019 by 维 朱

针对i.MX6的板子,系统运行正常。原系统使用qt4.8.5(不含opengl),因qt应用层软件功能需求需要opengl,因此自己交叉编译了qt5.4.1的源码并将其配置到imx6板子上,在运行测试程序时出现如下错误信息:

# ./TestAnimation -platform linuxfb

 

QML debugging is enabled. Only use this in a safe environment.
jzw;pwm_backlight_update_status:s_bl_en=1
QQuickWidget is not supported on this platform.
qrc:/animationtypes.qml:63:5: QML Image: Invalid image data: qrc:/images/firstWid/1-logo.png
qrc:/ClickableImageV3.qml:56:9: QML Image: Invalid image data: qrc:/images/firstWid/plane_up_1.png
qrc:/ClickableImageV3.qml:56:9: QML Image: Invalid image data: qrc:/images/firstWid/plane_bottom_1.png
qrc:/ClickableImageV3.qml:56:9: QML Image: Invalid image data: qrc:/images/firstWid/plane_mid_1.png
qrc:/animationtypes.qml:33:1: QML Image: Invalid image data: qrc:/images/firstWid/1.png
This plugin does not support createPlatformOpenGLContext!
Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 1, profile 0)
Aborted

 

在qt官方给出的一篇文章中发现(http://doc.qt.io/qt-5/embedded-linux.html):

Building Qt for a given device requires a toolchain and a sysroot. Additionally, some devices require vendor-specific adaptation code for EGL and OpenGL ES 2.0 support. This is not relevant for non-accelerated platforms, for example the ones using the LinuxFB plugin, which is meant for software-based rendering only.

因此我采用platform eglfs,qt5.4.1源码交叉编译配置方法如下:

vim $source_path/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

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)

QMAKE_INCDIR += /opt/tslib1.4/include
QMAKE_LIBDIR += /opt/tslib1.4/lib
QMAKE_INCDIR += /opt/libx11/include
QMAKE_LIBDIR += /opt/libx11/lib

QMAKE_INCDIR += /opt/opengl/include
QMAKE_LIBDIR += /opt/opengl/lib
QMAKE_LIBS += -lX11 -lxcb -lX11-xcb -lxcb-dri2 -lxcb-xfixes -lexpat -ldrm -lxml2 -lglapi -lEGL -lXext -lz -lXrender -ludev
QMAKE_INCDIR_OPENGL += /opt/opengl/include
QMAKE_INCDIR_OPENGL += /opt/libx11/include
QMAKE_LIBDIR_OPENGL += /opt/libx11/lib
QMAKE_LIBDIR_OPENGL += /opt/opengl/lib
QMAKE_LIBS_OPENGL = -lglapi -lEGL -lGL -lX11-xcb -lX11 -lxcb-dri2 -lxcb-xfixes -lxcb -lexpat -lxml2 \
-ldrm -lXext -lXdamage -lXfixes -lxcb-glx -lxcb-dri3 -lxcb-present -lxcb-sync \
-lxshmfence -lglapi
QMAKE_INCDIR_OPENGL_ES2 += /opt/opengl/include
QMAKE_INCDIR_OPENGL_ES2 += /opt/libx11/include
QMAKE_LIBDIR_OPENGL_ES2 += /opt/libx11/lib
QMAKE_LIBDIR_OPENGL_ES2 += /opt/opengl/lib
QMAKE_LIBS_OPENGL_ES2 = -lglapi -lEGL -lGL -lX11-xcb -lX11 -lxcb-dri2 -lxcb-xfixes -lxcb -lexpat -lxml2 \
-ldrm -lXext -lXdamage -lXfixes -lxcb-glx -lxcb-dri3 -lxcb-present -lxcb-sync \
-lxshmfence -lglapi
# 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)

 

qt5.4.1源码congiure配置如下:

./configure \
-v \
-prefix /opt/qt_5.4.1 \
-release \
-confirm-license \
-opensource \
-make libs \
-make examples \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-gui \
-kms \
-eglfs \
-widgets \
-no-xkb \
-glib \
-qt-zlib \
-qt-xcb \
-opengl es2 \
-xinput2 \
-qt-freetype \
-qt-xkbcommon \
-force-pkg-config \
-no-sse2 \
-no-openssl \
-no-libpng \
-no-libjpeg \
-no-icu \
-no-pulseaudio \
-no-sql-db2 \
-no-sql-ibase \
-no-sql-mysql \
-no-sql-oci \
-no-sql-odbc \
-no-sql-psql \
-no-sql-sqlite \
-no-sql-sqlite2 \
-no-sql-tds \
-no-mtdev \
-no-nis \
-no-cups \
-no-glib \
-no-iconv \
-no-separate-debug-info 

 

配置结果输出如下:

Build parts ............ libs examples
Mode ................... release
Using C++11 ............ yes
Using gold linker....... no
Using PCH .............. yes
Target compiler supports:
Neon ................. no

Qt modules and options:
Qt D-Bus ............... yes (loading dbus-1 at runtime)
Qt Concurrent .......... yes
Qt GUI ................. yes
Qt Widgets ............. yes
Large File ............. yes
QML debugging .......... yes
Use system proxies ..... no

Support enabled for:
Accessibility .......... yes
ALSA ................... no
CUPS ................... no
Evdev .................. yes
FontConfig ............. yes
FreeType ............... yes (system library)
Glib ................... no
GTK theme .............. no
HarfBuzz ............... yes (bundled copy)
Iconv .................. no
ICU .................... no
Image formats:
GIF .................. yes (plugin, using bundled copy)
JPEG ................. no
PNG .................. no
journald ............... no
mtdev .................. no
Networking:
getaddrinfo .......... yes
getifaddrs ........... yes
IPv6 ifname .......... yes
OpenSSL .............. no
NIS .................... no
OpenGL / OpenVG:
EGL .................. yes
OpenGL ............... yes (OpenGL ES 2.0+)
OpenVG ............... no
PCRE ................... yes (bundled copy)
pkg-config ............. yes
PulseAudio ............. no
QPA backends:
DirectFB ............. no
EGLFS ................ yes
KMS .................. yes
LinuxFB .............. yes
XCB .................. yes (bundled copy)
EGL on X ........... yes
GLX ................ no
MIT-SHM ............ yes
Xcb-Xlib ........... yes
Xcursor ............ yes (loaded at runtime)
Xfixes ............. yes (loaded at runtime)
Xi ................. no
Xi2 ................ yes
Xinerama ........... yes (loaded at runtime)
Xrandr ............. yes (loaded at runtime)
Xrender ............ yes
XKB ................ no
XShape ............. yes
XSync .............. yes
XVideo ............. yes
Session management ..... yes
SQL drivers:
DB2 .................. no
InterBase ............ no
MySQL ................ no
OCI .................. no
ODBC ................. no
PostgreSQL ........... no
SQLite 2 ............. no
SQLite ............... no
TDS .................. no
udev ................... yes
xkbcommon .............. yes (bundled copy, XKB config root: /usr/share/X11/xkb)
zlib ................... yes (bundled copy)

 

在运行测试程序时出现如下错误信息:

./root@freescale /$ ./TestAnimation -platform eglfs
QML debugging is enabled. Only use this in a safe environment.
libEGL warning: DRI2: xcb_connect failed
libEGL warning: DRI2: xcb_connect failed
Could not initialize egl display
Aborted

 

请教下是否在配置qt5.4.1源码时未配置正确?希望各位能提供下qt5编译的方法,谢谢!

Outcomes