Uploaded image for project: 'Qt Visual Studio Tools'
  1. Qt Visual Studio Tools
  2. QTVSADDINBUG-630

“Unresolved external symbol” errors when creating a Qt GUI application with Qt VS Tools

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 2.3.2
    • Build-time integration
    • None

    Description

      I already signaled this bug to Microsoft however the last feedback says that the bug is comming from the Qt build system. 

      This was the conclusion from Microsoft team: "Qt VS extension is owned by Qt (not VS). Qt build includes many custom steps which generate files and from your description it seems that the problem is in how those files are generated."

      I'll copy paste the bug description here: 

      To reproduce this bug it is simple. Unzip the "QtGuiApplication.zip" given folder (conserve this zip folder). Open the project file in the unzipped folder, start debug session, and see these abnormal errors that shouldn't occurs. 

      This GUI Application was created with Qt wizard, however the problem is from the compiler. I'll will explain next. 

      I found two paliative solutions :

      1) restart Visual Studio, create a new Qt GUI Application from the beginning. It can work this time. It's a stupid solution, but can work sometimes. 

      2) A better and systematic solution is this one: 
      comment Q_OBJECT (in the Dialog.h header file) then start debug session, the window of our program opens, wait 10 seconds, stop debug session. Now uncomment Q_OBJECT macro, then start again debug session, it should work and you'll see that from this instant it will work for ever. Logically after making these steps you'll not be able to reproduce the bug from this current project. But if you want to reproduce the bug another time, it is simple, you have to get another copy of the project file from the given zip folder. This is why I insisted to conserve the zip folder. 

      From the behavior seen in this 2nd solution we can heavily suspect that the problem comes from the Visual Studio Compiler

      The bug is already reported here in Qt forums, please read this topic there is many indication about the bug (For example, they say: "Yes. I don't understand why moc doesn't generate an empty .moc file and some warnings in such case, but it's how it works."): 
      https://forum.qt.io/topic/39908/solved-error-lnk2001-unresolved-external-symbol

      A similar bug is described here (They say: ""If you're using Visual Studio, delete the line Q_OBJECT from the header file, save the file, put Q_OBJECT back into the header file, save the file again. This should generate the moc_* file and should build and link correctly."): https://stackoverflow.com/questions/14170770/unresolved-external-symbol-public-virtual-struct-qmetaobject-const-thiscal

      It highly seems that the problem com from moc_* file that Visual Studio Compiler forget to generate where Q_OBJECT macro is here, and in some conditions...

      Now, I gave a max of info, you can reproduce the bug, and you have a begginnig of investigation about this bug.

      Please consider it. 
      Thanks

      PS: To help you investigate I gave you another zip folder ("QtGuiApplication2.zip") with another Qt GUI project with different paramenters but with absolutely the same bug inside.

      Attachments

        1. DialogItemType.PNG
          DialogItemType.PNG
          38 kB
        2. QtGuiApplication.zip
          428 kB
        3. QtGuiApplication2.zip
          428 kB
        4. QtProjectSettings.PNG
          QtProjectSettings.PNG
          49 kB
        5. RebuildSucceeded.PNG
          RebuildSucceeded.PNG
          46 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mecfc Miguel Costa
            navis-raven Dragoon Gryffoon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes