Important: Please read the Qt Code of Conduct -

Dynamic OpenGL and Qt5.7.0 build from source on Windows 7 problem (most related to QtWebEngine)

  • The purpose to build Qt from source is to use desktop OpenGL.
    So if anyone can point out what I did wrong during dynamically setting OpenGL source (default ANGLE, I want to make it using desktop OpenGL), it will be very helpful ;) Using Qt pre-built installation package is much easier.

    1. I add QT_OPENGL as a new environment variable to Windows environment variables, set it to be "desktop", restart, does not work. Did I set it correctly or there is something else I need to do?
    2. In the program,
    #include <MyGLWidget.h>
    #include <QApplication>
    int main(int argc, char *argv[])
        QApplication app(argc, argv);
        MyGLWidget win;
        win.resize(640, 480);;
        return app.exec();

    I have read that we should set application attribute before instantiating QApplication, so I feel the code might be wrong. But I don't know how to do it correctly...(

    Build Qt5.7.0 from source on Windows 7:
    I have tried several times and met different problems, most of them point to QtWebEngine. Then I use "-skip qtwebengine", new problem appears.
    I will describe them in order.
    Installed Perl (ActivePerl), Python(3.5.2), Windows SDK, DirectX SDK.
    All the compiling use "VS2013 x64 Cross Tools Command Prompt":

    1. configure -debug-and-release -opensource -platform win32-msvc2013 -opengl desktop, the jom.exe -j 10. With this configuration, it compiles very slow in QtWebEngine, takes about 3 hours and stopped when link QtWebEngineCored.dll, with error "out of memory". I see others got this "out of memory" before and solved by using "VS2013 x64 Cross Tools Command Prompt". But in my case, I am already using this command prompt. BTW, building the 3rd Party softwares in QtWebEngine is really slow, takes about 2 hours.
    2. configure -debug-and-release -opensource -platform win32-msvc2013 -opengl desktop -nomake examples -nomake tests -skip qtwebengine. The makefile does not report error while building, but after it finished, I checked the Qt5.7.0\qtbase\include, the are files in QtOpenGL, but empty in QtQuick, QtSvg, ... But I also need QtQuickView and other things.
      (I use similar configure command in linux (configure -opensource -platform win32-msvc2013 -opengl desktop -nomake examples -nomake tests -skip qtwebengine), it builds perfectly, with all header files I need in the include file)

    After building it for 4 days, I am now dizzy. Any ideas I can try next?
    I really need Qt with desktop OpenGL on Windows.

  • Lifetime Qt Champion

    @lilyofvalley said in Dynamic OpenGL and Qt5.7.0 build from source on Windows 7 problem (most related to QtWebEngine):

    QtQuick, QtSvg

    QtQuick, QtSvg are in their own modules not inside qtbase.
    Also if something is not built you should check the output of your configure call to see whether those parts are disabled due to missing dependencies.

  • I think after a successful build and install, the head files of QtQuick and QtSvg should be copied to qtbase\include\QtQuick and qtbase\include\QtSvg, also qtbase\lib, then other program will be able to find them through $$QTDIR \include and $$QTDIR \lib.
    Under linux, it did that.
    Under windows, should I manually copy them to the qtbase\include file?

  • Lifetime Qt Champion

    @lilyofvalley No, you should not copy anything.
    Did you check the output of the configure call as I suggested before?

  • Moderators

    As documented - choosing the OpenGL implementation at runtime needs to be done before you instantiate the application object i.e.:

    QApplication app(argc, argv);

    As for building Qt - If you don't build web engine and only use desktop OpenGL you don't need Perl or DirectX SDK. You don't need to specify platform if you set up the environment right (run vcvarsall.bat). It's also a good idea to use a prefix build - gives you much smaller and cleaner directory at the end and puts everything where it needs to be (i.e. includes and libs). QtQuick and QtSvg are separate modules so the includes won't be in qtbase. They will be in qtdeclarative and qtsvg. Use the prefix build to gather all modules, like the official prebuilt package does.

    This is how I usually build it (takes ~30 minutes on my machine):

    //assume Qt source is in C:\Qt\src
    //assume you build in C:\Qt\build
    //assume you install to C:\Qt\msvc2013_64
    SET PATH=%PATH%;C:\Programs\Python27;C:\Programs\jom; //adjust the paths to your needs
    "C:\Programs\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 //change amd64 to x86 if you build for 32bit
    cd C:\Qt
    mkdir build
    mkdir msvc2013_64
    cd build
    ..\src\configure -prefix %CD%\..\msvc2013_64 -debug-and-release -mp -opensource -confirm-license -nomake examples -nomake tests -opengl desktop -skip webengine
    jom -j8
    //builds for about 30 minutes
    nmake install
    //copies what's needed to the output directory
    cd ..
    rmdir /q /s build

  • @Chris-Kawa Thank you so much for the detailed explanation. Help me understand how the build works. I am able to compile now and got the desirable result!

Log in to reply