Important: Please read the Qt Code of Conduct -

[Solved] Cannot build 5.0 Beta2 project using OpenGL

  • Repost from
    Realized "Installation and Deployment" is the correct category

    I’ve tried everything (….well clearly not everything or it would be working) but I cannot get a 5.0 beta project that uses opengl to compile on Windows 7.

    I have “QT += core gui opengl widgets” in my pro file so the Qt OpenGL module should be available

    #include <QtOpenGL> is present. However, I get all sorts of compile errors like
    “‘GL_MODELVIEW’ : undeclared identifier”
    “‘glMatrixMode’: identifier not found”

    I THINK I have added the proper PATH, Include, and Lib variables pointing to the right folders, but at this point I'm not sure anymore.

    Clearly an opengl library somewhere isn’t being included properly but its driving me nuts which it is. I shouldn’t have to download opengl separately, right? Isn’t it included as part of Qt?

  • Moderators

    Qt5 uses Angle by default. You need to compile it yourself if you want to use OpenGL. OpenGL headers are not included with Qt, and you need to have a proper driver on your machine.

  • I'm currently trying to build QT5 from scratch (4 hr build and stuff keeps going wrong, life is misery) but could you clarify / correct me if I'm wrong?

    1. When you say build it yourself you mean Qt5 per , correct?

    2. I want to build an exe that runs fine on any win machine. I assume compiling with -opengl locks your executables in with either Nvidia or ATI? Should I be using angle?

    3. Stupid question, but what headers should I be including? When I try I keep getting macro redefinition errors such as glFloat.

  • Moderators

    Yes, correct.

    Probably not, OpenGL is platform-agnostic to a lage degree. Then again, angle is default for a reason.

    No idea, sorry. I do most of my coding on Linux, and here everything with regard to OpenGL just works. Make sure you do have your AMD/ Nvidia/ Intel drivers installed. Stock Windows includes OpenGL 1.1 only, Qt requires OpenGL 2.0.

  • I've solved the problem and feel very ashamed of my fail....

    OpenGl uses AngleProject which works fine, however, Angle doesn't include Glut support which you'll need to add yourself.

    1. download glut.h AND its accompanying glut32.lib from the internet. Depending on where you save them make sure to add their paths to the "INCLUDE" and "LIB" system variables in Projects Tab->Build Environment

    2. add #include "glut.h" to your code

    3. In Qt Creator right click your project in the projects window and select "Add Library" Chose "External library" (System Library is probably cleaner, but I'll let you add glut.h to your system if you choose). Browse to the library file AND make sure that the Include path is correct. DO NOT trust Qt Creator to auto complete the Include Path. I didn't look at it and QT Creator auto completed the wrong path, took me 30 min to realize that was messing up my linker.

  • I am also facing the same build issue with the latest qt5 source code when configuring the build with -no-opengl option.
    Is there any soft fix to build it.
    My requirement is I need only qtquick1,I dont need qtquick2.Is there a way to enable only qtquick1 only.if yes,Please let me know

Log in to reply