qtopenglbitbakeeglxcb

How to enable GLX and EGL integration with XCB for Qt5 applications in Yocto Linux?


I have an application running on Yocto Zeus 3.0.1 with Qt5 and relies on OpenGL EGL. The application builds fine, but fails with the following message:

QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled

I have added all the needed OpenGL drivers in image .bb file:

IMAGE_INSTALL += "libegl-mesa libgl-mesa libegl-mesa-dev libgl-mesa-dev libgles3-mesa-dev mesa-megadriver"

The following is my qt5/qtbase_%.bbappend file.

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

PACKAGECONFIG_append = "gles2 mtdev sql-sqlite glib fontconfig gif accessibility"

PACKAGECONFIG_append = " widgets"

do_configure_prepend () {
    cat >> ${S}/mkspecs/linux-oe-g++/qmake.conf <<EOF
    # the below indentation is important - Soham

QMAKE_LIBS_EGL += -lEGL -ldl -lglib-2.0 -lpthread
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lgsl -lEGL -ldl -lglib-2.0 -lpthread

QMAKE_CFLAGS += -DLINUX=1 -DWL_EGL_PLATFORM -DEGL_API_FB=1
QMAKE_CXXFLAGS += -DLINUX=1 -DWL_EGL_PLATFORM -DEGL_API_FB=1

QT_QPA_DEFAULT_PLATFORM = xcb
load(qt_config)
EOF
}

I am building the application on the target itself. Therefore, I added the -dev files.

What am I missing here?


Solution

  • I needed to change my qtbase_%.bbappend. It should look like the following:

    FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
    
    IMAGE_FEATURES += "accessibility"
    IMAGE_FEATURES += "gles2 mtdev sql-sqlite glib fontconfig gif accessibility xcb egl libs xkb xkmcommon"
    QT_CONFIG_FLAGS_APPEND = "-xcb"
    
    PACKAGECONFIG_append = " widgets"
    
    DEPENDS += "gsl libxkbcommon"
    
    RDEPENDS_${PN} += "gsl xrandr libxkbcommon"
    
    do_configure_prepend () {
        # the below indentation is important - Soham
        cat > ${S}/mkspecs/oe-device-extra.pri <<EOF
    
    QMAKE_LIBS_EGL += -lEGL -ldl -lglib-2.0 -lpthread -lX11 -lxcb -lXrandr -lxcb-glx
    QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lgsl -lEGL -ldl -lglib-2.0 -lpthread -lX11 -lxcb -lXrandr -lxcb-glx
    
    QMAKE_CFLAGS += -DLINUX=1 -DWL_EGL_PLATFORM -DEGL_API_FB=1 -DXCB_USE_EGL -DXCB_USE_GLX
    QMAKE_CXXFLAGS += -DLINUX=1 -DWL_EGL_PLATFORM -DEGL_API_FB=1 -DXCB_USE_EGL -DXCB_USE_GLX
    
    QT_QPA_DEFAULT_PLATFORM = xcb
    QT_XCB_GL_INTEGRATION = xcb_egl
    
    EOF
    }