You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Monday, January 25th 2016, 1:49pm

Build QT OpenGL GUI in Linux


I don't have too much experience with QT, so I need some help with this problem:

I am developing a framework in Linux, where I want to create a basic OpenGL GUI class which displays an OpenGL window and maybe some buttons, but not necessarily. From this framework, one should be able to create different applications, so there is a core module with core functionality and a application module for creating applications. I now want to have the possibility to create a different OpenGL GUI for different applications, where the overhead in the application should only be the drawing method. I would like to pass this function pointer to the OpenGL GUI class and let it draw the application specific items. If thats too much of a problem, I would extend this basic class for each application, where I also only have to define a drawing function for this particular application. So my steps to achive this would be:

1.) Build Qt (done)
2.) Import Qt libs into framework using cmake
3,) Use functionality within the framework

Step 1. was straight forward. Step 2 and 3 are already a problem. I add those libs to the cmake lists file like this:


but the output is this:

Source code

undefined reference to `QGLFormat::QGLFormat(QFlags<QGL::FormatOption>, int)'
undefined reference to `vtable for OpenGLWindow'
undefined reference to `QGLWidget::QGLWidget(QGLFormat const&, QWidget*, QGLWidget const*, QFlags<Qt::WindowType>)'
undefined reference to `QGLFormat::~QGLFormat()'
undefined reference to `QGLWidget::~QGLWidget()'
undefined reference to `QWidget::update()'

and other similar linker errors. The thing is: I could install Qt on the system, but I want it to use the pre-built Qt libraries from the framework, such that a user can checkout the framework and doesn't have to install any 3rd-party software in order to get the framework running. I've read, that I need a ".pro" file where I can add the Qt modules, but I use cmake and I have no idea, how to combine those 2 in the most clean and efficient way, without a lot of overhead.

I would be glad to get some advice from you, thanks!