I am developing simple gui app for a client on Raspberry pi running Ubuntu(Mate) 16.04 using Qt 5.5.1 and OpenCV for some face recognition (all C++) using 5MP pi camera.

The framerate/CPU usage through Qt+OpenCV via v4l2 was poor { 5-7 fps and hogged 50-70% cpu. } So I integrated the raspicam/raspistill code so I can show a HW driven preview window (>30fps, 1-2% CPU).

Unfortunately Qt clashing with GL/GLES as used from userland code at startup and I get the following error at Qt/GL init phase. Code: Select all

Unable to find an X11 visual which matches EGL config 20 Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface

Here are the libraries used to link the exe... in case they show any conflicts

QT link libs :

-L/usr/local/qt551/lib -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Multimedia 
-lQt5MultimediaWidgets -lQt5Network

userland link libs :

-Wl,-rpath,../userland/lib ../userland/lib/libbrcmGLESv2.so ../userland/lib/libbrcmEGL.so 
../userland/lib/libmmal_core.so ../userland/lib/libmmal_util.so 
../userland/lib/libmmal_vc_client.so ../userland/lib/libvcsm.so ../userland/lib/libbcm_host.so 
../userland/lib/libvchostif.a ../userland/lib/libvcfiled_check.a ../userland/lib/libvchiq_arm.so 
../userland/lib/libvcos.so ../userland/lib/libkhrn_client.a
Code: Select all

opencv link libs :

-L/usr/local/ocv3/lib -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann
 -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect
 -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_video
 -lopencv_videoio -lopencv_videostab 

mmal link libs :

-lmmal -lmmal_core -lmmal_util -lmmal_vc_client -lmmal_components -lcontainers -lvcos
 -lvcsm -lvchiq_arm

Quick search shows this could have a Qt based solution/workaround from these posts

  1. Question to Hardkernel (mainly) about my buggy mali
  2. Workaround EGL initialization failure due visual mismatch

Will those odroid solution/workaround apply for integrating Qt UI with other GL/GLES code? Just checking before I attempt recompiling Qt-base on Raspberry Pi - Ubuntu Mate as suggested there with a patch.

OR If anyone has integrated Qt with userland or other 3rd party GL/GLES C++ code successfully please share your approach.

  • Please don't write Solved into the headline. There is a much better way to show that your question has a solution. Please move your SOLUTION from the question body into an answer. This is the way this site works. After two days you can accept your own answer. This will show other users that it has a solution.
    – Ingo
    Commented Apr 15, 2019 at 11:51

1 Answer 1


I tried excluding GL related shared libraries at linking to trace the function dependencies and was surprised brcmGLESv2 brcmEGL and vcos were not even needed for linking!

In fact vcos was the one that broke Qt GL dependency. So leaving out brcmGLESv2 brcmEGL and vcos allows Qt GUI to start up and I can show the raspicam preview "over" a qt dialog window now at 30-60 fps and 0.3% CPU usage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.