Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Turning off Shadow build leads to a bunch of weird linker errors



  • I do not want to use shadow build my own reasons, but I just discovered that my project links successfully only when shadow build is turned on. If I turn it off, I get 5 linker errors regarding 1(!) single class which lives in the same .h file with another class that does not produce linker errors.
    What is wrong here?

    Assuming that I can live with shadow build for the time being, I still need to be able to run the output .exe standalone (outside of QT Creator). I copy all of the QT5 .dlls that the debug and release .exes require, but they still do not start. They throw "This application was unable to start correctly (0xc00000007b)" errors.
    What is wrong here?


  • Lifetime Qt Champion

    @In-Fo said in Turning off Shadow build leads to a bunch of weird linker errors:

    I still need to be able to run the output .exe standalone

    Check https://doc.qt.io/qt-5/deployment.html, there is more to it than copying Qt5 dlls (plug-ins for example).

    Also, you did not tell what the linker error actually is.



  • The linker errors refer to unresolved symbols that are methods of my class, like I said.

    newform.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl fileHelperSignalHelper::metaObject(void)const " (?metaObject@fileHelperSignalHelper@@UEBAPEBUQMetaObject@@XZ)

    newform.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __cdecl fileHelperSignalHelper::qt_metacast(char const *)" (?qt_metacast@fileHelperSignalHelper@@UEAAPEAXPEBD@Z)

    newform.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __cdecl fileHelperSignalHelper::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@fileHelperSignalHelper@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

    newform.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl fileHelperSignalHelper::saveProgressChanged(unsigned int)" (?saveProgressChanged@fileHelperSignalHelper@@QEAAXI@Z) referenced in function "private: void __cdecl newForm::handleBtnSaveCurrent(void)" (?handleBtnSaveCurrent@newForm@@AEAAXXZ)

    fileHelper.obj:-1: error: LNK2001: unresolved external symbol "public: void __cdecl fileHelperSignalHelper::saveProgressChanged(unsigned int)" (?saveProgressChanged@fileHelperSignalHelper@@QEAAXI@Z)

    newform.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const fileHelperSignalHelper::staticMetaObject" (?staticMetaObject@fileHelperSignalHelper@@2UQMetaObject@@B)


  • Lifetime Qt Champion

    @In-Fo Looks like you do not build/link auto-generated moc_*.cpp file



  • What do you mean by "I do not"?



  • @jsulm said in Turning off Shadow build leads to a bunch of weird linker errors:

    @In-Fo Looks like you do not build/link auto-generated moc_*.cpp file

    Can you elaborate on "I do not build auto-generated file"? What manual actions outside of Qt Creator are required to have it build that auto-generated file?


  • Lifetime Qt Champion

    @In-Fo Take a look here: https://doc.qt.io/qt-5/why-moc.html
    Usually you do not have to care about it as QMake will do. It will add instructions to the makefiles to generate, build and link moc files. In your case it seems not to happen for what ever reason. You can post the whole build log.


Log in to reply