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. cppwinrt library usage refuses to compile in Qt projects
Forum Updated to NodeBB v4.3 + New Features

cppwinrt library usage refuses to compile in Qt projects

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 2.4k 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.
  • S Offline
    S Offline
    sebkajeka
    wrote on 23 Apr 2017, 23:02 last edited by sebkajeka
    #1

    Microsoft have a C++ UWP library called cppwinrt, this provides a modern C++ platform for interacting with the Windows Runtime without faffing about with the old WRL templates and COM objects. It's a header only library and as such setup should be simple.

    https://github.com/Microsoft/cppwinrt

    I've add the library header directory to the INCLUDEPATH of a template MSVC2015 QWidgets project and have included the relevant cppwinrt header files. I have installed all the requires Windows kits however I am unable to compile a project without getting the error.

    /Windows Kits/10/include/10.0.15063.0/um/WindowsNumerics.impl.(27): Parse error at "winrt"
    

    Unfortuantely my knowledge of Makefiles is lacking so i'm unsure what could be causing this issue. I can compile and use the library fine in Visual Studio. From a quick look at the cppwinrt library source it relies heavily on macros which redefine macros that are within the WindowsKits. Could it potentially be an include order issue?

    Full compile log below:

    https://pastebin.com/fHXNdv5G

    Example Project:
    https://ufile.io/iasrp

    J 1 Reply Last reply 24 Apr 2017, 04:56
    0
    • S sebkajeka
      23 Apr 2017, 23:02

      Microsoft have a C++ UWP library called cppwinrt, this provides a modern C++ platform for interacting with the Windows Runtime without faffing about with the old WRL templates and COM objects. It's a header only library and as such setup should be simple.

      https://github.com/Microsoft/cppwinrt

      I've add the library header directory to the INCLUDEPATH of a template MSVC2015 QWidgets project and have included the relevant cppwinrt header files. I have installed all the requires Windows kits however I am unable to compile a project without getting the error.

      /Windows Kits/10/include/10.0.15063.0/um/WindowsNumerics.impl.(27): Parse error at "winrt"
      

      Unfortuantely my knowledge of Makefiles is lacking so i'm unsure what could be causing this issue. I can compile and use the library fine in Visual Studio. From a quick look at the cppwinrt library source it relies heavily on macros which redefine macros that are within the WindowsKits. Could it potentially be an include order issue?

      Full compile log below:

      https://pastebin.com/fHXNdv5G

      Example Project:
      https://ufile.io/iasrp

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 Apr 2017, 04:56 last edited by
      #2

      @sebkajeka Can you show your pro file?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sebkajeka
        wrote on 24 Apr 2017, 10:07 last edited by
        #3

        It's included in the project but for ease:

        QT       += core gui
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = untitled
        TEMPLATE = app
        
        QMAKE_CXXFLAGS += /std:c++latest
        
        # The following define makes your compiler emit warnings if you use
        # any feature of Qt which as been marked as deprecated (the exact warnings
        # depend on your compiler). Please consult the documentation of the
        # deprecated API in order to know how to port your code away from it.
        DEFINES += QT_DEPRECATED_WARNINGS
        
        # You can also make your code fail to compile if you use deprecated APIs.
        # In order to do so, uncomment the following line.
        # You can also select to disable deprecated APIs only up to a certain version of Qt.
        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
        
        LIBS += -lwindowsapp
        
        SOURCES += main.cpp\
                mainwindow.cpp
        
        INCLUDEPATH += $$PWD/10.0.15063.0
        
        HEADERS  += mainwindow.h
        
        FORMS    += mainwindow.ui
        
        J 1 Reply Last reply 24 Apr 2017, 10:50
        0
        • S sebkajeka
          24 Apr 2017, 10:07

          It's included in the project but for ease:

          QT       += core gui
          
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          
          TARGET = untitled
          TEMPLATE = app
          
          QMAKE_CXXFLAGS += /std:c++latest
          
          # The following define makes your compiler emit warnings if you use
          # any feature of Qt which as been marked as deprecated (the exact warnings
          # depend on your compiler). Please consult the documentation of the
          # deprecated API in order to know how to port your code away from it.
          DEFINES += QT_DEPRECATED_WARNINGS
          
          # You can also make your code fail to compile if you use deprecated APIs.
          # In order to do so, uncomment the following line.
          # You can also select to disable deprecated APIs only up to a certain version of Qt.
          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
          
          LIBS += -lwindowsapp
          
          SOURCES += main.cpp\
                  mainwindow.cpp
          
          INCLUDEPATH += $$PWD/10.0.15063.0
          
          HEADERS  += mainwindow.h
          
          FORMS    += mainwindow.ui
          
          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 24 Apr 2017, 10:50 last edited by
          #4

          @sebkajeka I think for WinRT you need Qt for WinRT (you can install it easily using Qt Maintenance Tool).

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 24 Apr 2017, 12:21
          1
          • J jsulm
            24 Apr 2017, 10:50

            @sebkajeka I think for WinRT you need Qt for WinRT (you can install it easily using Qt Maintenance Tool).

            S Offline
            S Offline
            sebkajeka
            wrote on 24 Apr 2017, 12:21 last edited by
            #5

            @jsulm This paradigm differs from Qt for WinRT as it allows you to use UWP (WinRT) API's in a non-sandboxed C++ application.

            J 1 Reply Last reply 24 Apr 2017, 12:48
            0
            • S sebkajeka
              24 Apr 2017, 12:21

              @jsulm This paradigm differs from Qt for WinRT as it allows you to use UWP (WinRT) API's in a non-sandboxed C++ application.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 24 Apr 2017, 12:48 last edited by
              #6

              @sebkajeka /Windows Kits/10/include/10.0.15063.0/um/WindowsNumerics.impl.(27): Parse error at "winrt" - what is actually at line 27 in that file?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sebkajeka
                wrote on 26 Apr 2017, 12:57 last edited by
                #7

                Upon inspection of base.h I assume this has something to do with the WINDOWS_NUMERICS_BEGIN_NAMESPACE which is referenced in line 27 of WindowsNumerics.impl.h and is redefined in base.h as

                #define _WINDOWS_NUMERICS_BEGIN_NAMESPACE_ namespace winrt::Windows::Foundation::Numerics
                

                The issue lies with the definition of the macros

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sebkajeka
                  wrote on 26 Apr 2017, 13:41 last edited by
                  #8

                  @sebkajeka

                  This is caused by the Qt MOC compiler and cppwinrt headers.

                  To build successfully wrap the cppwinrt #includes in:

                  #ifndef Q_MOC_RUN
                  #endif

                  1 Reply Last reply
                  1

                  1/8

                  23 Apr 2017, 23:02

                  • Login

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