Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-20315

Linker failure to unused method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • Qt Creator 4.6.0
    • None
    • Windows 10

      Qt Creator 4.6.0

      Qt 5.10.1 (MSVC 2015, 32 bit)

      MSVC C++ Compiler 15.0 (x86_amd64)

    Description

      While writing a method for the derived QObject class, I accidentally named it setCustomEvent(). After building the project there were linker issues and I realized my mistake.

      After refactoring and changing the method name to logCustomEvent() I tried to rebuild once more. Now neither the mainwindow class nor the derived class use that method name, but linker throws issue for both of them (mainwindow never even had a method with that name):

      mainwindow.obj:-1: error: LNK2001: unresolved external symbol "protected: virtual void __cdecl QObject::setCustomEvent(class QEvent *)" (?setCustomEvent@QObject@@MEAAXPEAVQEvent@@@Z)

      gazecomunicator.obj:-1: error: }}{{LNK2001: unresolved external symbol "protected: virtual void __cdecl QObject::setCustomEvent(class QEvent *)" (?setCustomEvent@QObject@@MEAAXPEAVQEvent@@@Z)

      I tried following:

      • Clean project + Run Qmake + Rebuild project
      • Manually deleting build folder and repeat clean+qmake+build
      • Removing Q_OBJECT macro and comment out all signal/slot uses, then add it back
      • Adding the setCustomEvent() method to both mainwindow and derived class. (Linking still fails for mainwindow but the issue disappears for derived class)
      • Rolling back the code to the point where I know it worked and make clean+qmake+build
      • Deleting the code and making a fresh clone from git

      Nothing seems to work and the linking issue always appears

      UPDATE: The same issue exists after porting to MSVC2017 and trying to build

      UPDATE 2: Bug disappeared after reinstallation of Qt (identical  options; Qt Creator 4.6.0, Qt 5.10.1, MSVC 2015 MSVC c++ 15.0)

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kosjar Nikolai Kosjar
              stribor14 Mirko Kokot
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes