Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt stop compiling giving windows.h error

Qt stop compiling giving windows.h error

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 459 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • carolsC Offline
    carolsC Offline
    carols
    wrote on last edited by carols
    #1

    My application was compiling correctly but suddenly, after minor code changes, it started to give this error.

    In file included from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/winbase.h:40:0,
    from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/windows.h:70,
    from C:\Qt\5.12.12\mingw73_64\include/QtCore/qt_windows.h:64,
    from C:\Qt\5.12.12\mingw73_64\include/QtGui/qopengl.h:49,
    from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qsggeometry.h:44,
    from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qsgnode.h:43,
    from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qsgrendererinterface.h:43,
    from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qquickwindow.h:44,
    from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qquickview.h:43,
    from C:\Qt\5.12.12\mingw73_64\include/QtQuick/QQuickView:1,
    from qtquick2applicationviewer\qtquick2applicationviewer.h:14,
    from qtquick2applicationviewer\qtquick2applicationviewer.cpp:11:
    C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/utilapiset.h:28:1: error: expected unqualified-id before '}' token
    }
    ^

    I checked my code and i could not find anything strange. It seems something related to windows.h.

    So i tried to create a new project from QtCreator. I created a Qt Quick application and i only add the inclusion of windows.h

    #include <windows.h>
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    
    int main(int argc, char *argv[])
    {
    #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    #endif
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
    
        return app.exec();
    }
    

    and it is also giving this error

    C:\Qt\Tools\mingw730_64\x86_64-w64-mingw32\include\utilapiset.h:28: error: expected unqualified-id before '}' token
    In file included from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/winbase.h:40:0,
    from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/windows.h:70,
    from ..\ProvaWindows\main.cpp:1:
    C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/utilapiset.h:28:1: error: expected unqualified-id before '}' token
    }
    ^

    I can't understand why it suddendly stop compiling.

    NOTE: I'm having this error using MinGW 7.3.0 64 bit, if i change compiler and for example i use the same MinGW 7.3.0 but 32 bit, i have no errors!

    Please help!
    Thanks

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Are you sure it every compiled with MinGW 7.3 with 64bits? I would guess no.
      Try to compile a simple main.cpp without any Qt includes but <windows.h> and see if you get errors - if so I don't see what Qt can do against it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      carolsC 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Are you sure it every compiled with MinGW 7.3 with 64bits? I would guess no.
        Try to compile a simple main.cpp without any Qt includes but <windows.h> and see if you get errors - if so I don't see what Qt can do against it.

        carolsC Offline
        carolsC Offline
        carols
        wrote on last edited by carols
        #3

        @Christian-Ehrlicher Hi, thanks for your reply! I'm sure that i was compiling with MinGW 7.3 64bits, the application was running on my PC correctly. Then i add a class and did some changes, i tried to compile again and it gave the error. However, has you suggested, I created a c++ application (no Qt include) and i add the include of windows.h in the main.cpp. I have the same error.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          So your installation is somewhat broken - no Qt problem.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          carolsC 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            So your installation is somewhat broken - no Qt problem.

            carolsC Offline
            carolsC Offline
            carols
            wrote on last edited by
            #5

            @Christian-Ehrlicher yes, i found that the file utilapiset.h had something wrong inside it (i don't know how and who had modified it). I fixed it and not it works! Thanks!

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved