Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt CMake Semantic Issue
Forum Updated to NodeBB v4.3 + New Features

Qt CMake Semantic Issue

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 5 Posters 2.8k Views 2 Watching
  • 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.
  • M Offline
    M Offline
    MCey
    wrote on 24 Aug 2018, 01:25 last edited by aha_1980
    #1

    Hi
    I am having very annoying problems with even fresh project on Qt with CMake. I have no idea what cause such warnings and errors below:

    mainwindow.cpp:6: error: allocation of incomplete type 'Ui::MainWindow'
    mainwindow.h:7: forward declaration of 'Ui::MainWindow'
    mainwindow.cpp:8: error: member access into incomplete type 'Ui::MainWindow'
    mainwindow.h:7: forward declaration of 'Ui::MainWindow'
    mainwindow.cpp:13: warning: deleting pointer to incomplete type 'Ui::MainWindow' may cause undefined behavior
    mainwindow.h:7: forward declaration of 'Ui::MainWindow'

    All of them seems as semantic issue and program could be run.
    What is wrong with these errors!

    J A A 3 Replies Last reply 24 Aug 2018, 05:32
    0
    • M MCey
      24 Aug 2018, 01:25

      Hi
      I am having very annoying problems with even fresh project on Qt with CMake. I have no idea what cause such warnings and errors below:

      mainwindow.cpp:6: error: allocation of incomplete type 'Ui::MainWindow'
      mainwindow.h:7: forward declaration of 'Ui::MainWindow'
      mainwindow.cpp:8: error: member access into incomplete type 'Ui::MainWindow'
      mainwindow.h:7: forward declaration of 'Ui::MainWindow'
      mainwindow.cpp:13: warning: deleting pointer to incomplete type 'Ui::MainWindow' may cause undefined behavior
      mainwindow.h:7: forward declaration of 'Ui::MainWindow'

      All of them seems as semantic issue and program could be run.
      What is wrong with these errors!

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 Aug 2018, 05:32 last edited by
      #2

      @MCey said in Qt CMake Semantis Issue:

      All of them seems as semantic issue and program could be run

      Could be run? How? These are compiler errors!
      Do you include "ui_mainwindow.h" in mainwindow.cpp?

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

      1 Reply Last reply
      2
      • M MCey
        24 Aug 2018, 01:25

        Hi
        I am having very annoying problems with even fresh project on Qt with CMake. I have no idea what cause such warnings and errors below:

        mainwindow.cpp:6: error: allocation of incomplete type 'Ui::MainWindow'
        mainwindow.h:7: forward declaration of 'Ui::MainWindow'
        mainwindow.cpp:8: error: member access into incomplete type 'Ui::MainWindow'
        mainwindow.h:7: forward declaration of 'Ui::MainWindow'
        mainwindow.cpp:13: warning: deleting pointer to incomplete type 'Ui::MainWindow' may cause undefined behavior
        mainwindow.h:7: forward declaration of 'Ui::MainWindow'

        All of them seems as semantic issue and program could be run.
        What is wrong with these errors!

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 25 Aug 2018, 17:46 last edited by aha_1980
        #3

        @MCey
        the annotations may come from the Clang Code Model.

        do they go away after successful build (and maybe project reload)?

        @jsulm nowadays the Clang warnings/errors appear in the Issues window too...

        Qt has to stay free or it will die.

        1 Reply Last reply
        1
        • M MCey
          24 Aug 2018, 01:25

          Hi
          I am having very annoying problems with even fresh project on Qt with CMake. I have no idea what cause such warnings and errors below:

          mainwindow.cpp:6: error: allocation of incomplete type 'Ui::MainWindow'
          mainwindow.h:7: forward declaration of 'Ui::MainWindow'
          mainwindow.cpp:8: error: member access into incomplete type 'Ui::MainWindow'
          mainwindow.h:7: forward declaration of 'Ui::MainWindow'
          mainwindow.cpp:13: warning: deleting pointer to incomplete type 'Ui::MainWindow' may cause undefined behavior
          mainwindow.h:7: forward declaration of 'Ui::MainWindow'

          All of them seems as semantic issue and program could be run.
          What is wrong with these errors!

          A Offline
          A Offline
          ambershark
          wrote on 26 Aug 2018, 06:46 last edited by ambershark
          #4

          @MCey Can we see your CMakeLists.txt ... this looks like you didn't moc your interface objects.

          Without seeing your cmake, here's a couple ideas:

          1. Make sure you have set(CMAKE_AUTOMOC ON)
          2. Use the macro to wrap your UI files:
          qt5_wrap_ui(UI_SRC
             ui/MainWindow.ui
          )
          
          ...
          
          add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC})
          

          Don't just copy that verbatim though. You need to adjust to your cmake, or share it and I'll help you. :)

          Edit: I missed this part:

          All of them seems as semantic issue and program could be run.

          If the program runs then it isn't a cmake issue then it's probably just the parser that the above posts talk about.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          1
          • Q Offline
            Q Offline
            qtcat
            wrote on 26 Nov 2018, 09:54 last edited by
            #5

            Im having exactly this problem too.
            Im creating a new project from scratch, and the first thing i see are errors :D

            I assume there will be more users that encouter this error - so i ask:
            How can we get rid of this?

            0_1543226004314_hallowelt_fehler.png

            J 1 Reply Last reply 26 Nov 2018, 11:29
            2
            • Q qtcat
              26 Nov 2018, 09:54

              Im having exactly this problem too.
              Im creating a new project from scratch, and the first thing i see are errors :D

              I assume there will be more users that encouter this error - so i ask:
              How can we get rid of this?

              0_1543226004314_hallowelt_fehler.png

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 26 Nov 2018, 11:29 last edited by jsulm
              #6

              @qtcat Did you build your app?
              ui_mainwindow.h is a file which is generated during build. If it is not yet there (because you did not yet build), QtCreator will show this errors/warnings because it does not know what Ui::MainWindow, which comes from that generated file, is.

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

              1 Reply Last reply
              3

              • Login

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