Important: Please read the Qt Code of Conduct -

Problem Compiling Widget application, Linux

  • Hi,

    I have problems linking a widgets application. The error I get looks like this:

    CMakeFiles/test/src/moc_TestClass.cpp.o:([_ZTV28TestClass]+0x218): undefined reference to `non-virtual thunk to QWidget::redirected(QPoint*) const'
    CMakeFiles/test/src/moc_TestClass.cpp.o:([_ZTV28TestClass]+0x220): undefined reference to `non-virtual thunk to QWidget::sharedPainter() const'
    CMakeFiles/test/src/moc_TestClass.cpp.o:([_ZTI28TestClass]+0x10): undefined reference to `typeinfo for QDialog'
    libs/libmylib.a(mylib.cpp.o): In function `mylib_init':
    mylib.cpp:(.text+0x4b): undefined reference to `QApplication::QApplication(int&, char**, int)'
    collect2: error: ld returned 1 exit status

    I have no idea what is going on. In target_link_libraries I have the packages:

    target_link_libraries(  ${PROJECT_NAME}

    what is going wrong?

  • Lifetime Qt Champion

    @maxwell31 said in Problem Compiling Widget application, Linux:

    QApplication::QApplication(int&, char**, int)

    This is a Qt4 ctor:

    Looks like you're picking up the Qt4 include files.

Log in to reply