[SOLVED] DEPENDPATH and INCLUDEPATH



  • Hello guys

    I'm having trouble with the .pro file. I have one external sub-classed QDialog and I want to start it when I select one action from the menu bar. When in my .pro file I specify the INCLUDEPATH with the HEADERS directory like this:

    @#-------------------------------------------------

    Project created by QtCreator 2012-11-28T09:23:03

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = myApp
    TEMPLATE = app

    INCLUDEPATH = /home/martin/myDialog

    SOURCES += main.cpp
    mainwindow.cpp
    /home/martin/myDialog/myDialog.cpp

    RESOURCES = resources.qrc

    HEADERS += mainwindow.h
    myDialog.h@

    I get the next message 4 times after compiling:

    @undefined reference to 'vtable for myDialog'@

    I know its something about the linker, but when I specify the .pro like this:

    @#-------------------------------------------------

    Project created by QtCreator 2012-11-28T09:23:03

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = myApp
    TEMPLATE = app

    DEPENDPATH += /home/martin/myDialog

    INCLUDEPATH = /home/martin/myDialog

    SOURCES += main.cpp
    mainwindow.cpp
    myDialog.cpp

    RESOURCES = resources.qrc

    HEADERS += mainwindow.h
    myDialog.h@

    Everything works fine. I've read "qmake variables documentation":http://doc.qt.digia.com/qt/qmake-variable-reference.html but could not understand why I need the DEPENDPATH variable even though with INCLUDEPATH I specify headers and SOURCES afterwards. Any ideas?

    Thanks in advance!



  • Hello guys!

    I think I found the answer. The reason: I read "this post":http://qt-project.org/forums/viewthread/11447 Then realized that myDialog.cpp had dependencies inside its directory (I suppose these are the moc files from Q_OBJECT of myDialog.cpp). So I need DEPENDPATH, to resolve dependencies where specified. When DEPENDPATH is not defined, no moc_myDialog.cpp file is created.

    I think this is it, because it also worked with VPATH variable:
    @
    #-------------------------------------------------

    Project created by QtCreator 2012-11-28T09:23:03

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = myApp
    TEMPLATE = app

    VPATH = /home/martin/myDialog

    INCLUDEPATH = /home/martin/myDialog

    SOURCES += main.cpp
    mainwindow.cpp
    myDialog.cpp

    RESOURCES = resources.qrc

    HEADERS += mainwindow.h
    myDialog.h@

    Regards.



  • The error you described mostly comes from changes in your project file, but forgot to run the qmake again.
    But if you fix did the trick I might be wrong ;-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.