PDA

View Full Version : linker problem in plugin, undefined reference to `Core::....



Bavooo
6th March 2012, 00:41
I'm building some plugins for QT Creator, and some are finished, but sometimes I bump in the undefined reference to .. error. I had it when i tried to use something like:


CppEditor::Internal::CPPEditorWidget *testccped = qobject_cast<CppEditor::Internal::CPPEditorWidget *>(textEditor->widget());

error:

./release\extractmethod.o:extractmethod.cpp:(.text+0 x3f7): undefined reference to 'CppEditor::Internal::CPPEditorWidget::staticMetaO bject'

So I didn't found the problem back then, but now I have it again. And it would motivate me if I could fix this.
So the case now:

my pro file: (My apologies for the messy pro file, the cleaning part still has to come)

TARGET = RefactoringPlugin
CONFIG += release
TEMPLATE = lib

DEFINES += REFACTORINGPLUGIN_LIBRARY


# RefactoringPlugin files

SOURCES += refactoringpluginplugin.cpp \
methoderenamedialog.cpp \
dialog.cpp \
extractmethod.cpp \
debugdialog.cpp \
extractmethoddialog.cpp \
gensetget.cpp


HEADERS += refactoringpluginplugin.h\
refactoringplugin_global.h\
refactoringpluginconstants.h \
methoderenamedialog.h \
dialog.h \
extractmethod.h\
debugdialog.h \
extractmethoddialog.h \
gensetget.h


OTHER_FILES = RefactoringPlugin.pluginspec


# Qt Creator linking
QTC_SOURCE_DIR = C:/qt-creator-2.4.1-src
IDE_SOURCE_TREE = $$QTC_SOURCE_DIR
QTC_BUILD_DIR = C:/qtcr24

include($$QTC_SOURCE_DIR/src/qtcreatorplugin.pri)
include($$QTC_SOURCE_DIR/src/plugins/coreplugin/coreplugin.pri)
include($$QTC_SOURCE_DIR/src/plugins/texteditor/texteditor.pri)
include($$QTC_SOURCE_DIR/src/plugins/coreplugin/coreplugin.pri)
include($$QTC_SOURCE_DIR/src/plugins/vcsbase/vcsbase.pri)
include($$QTC_SOURCE_DIR/src/libs/utils/utils.pri)
include($$QTC_SOURCE_DIR/src/libs/cplusplus/cplusplus.pri)
include($$QTC_SOURCE_DIR/src/plugins/cppeditor/cppeditor_dependencies.pri)
include($$IDE_SOURCE_TREE/src/plugins/coreplugin/coreplugin.pri )
include($$IDE_SOURCE_TREE/src/plugins/texteditor/texteditor.pri )
include($$QTC_SOURCE_DIR/src/plugins/cppeditor/cppeditor.pri)
include($$QTC_SOURCE_DIR/src/plugins/cpptools/cpptools.pri)
include($$QTC_SOURCE_DIR/src/plugins/locator/locator.pri)

LIBS += -LC:/qtcr24/bin \
-LC:/qtcr24/lib/qtcreator/plugins/Nokia/ \
-LC:/qtcr24/lib/qtcreator/plugins \
-LC:/qtcr24/src/plugins/cppeditor/release




DESTDIR = $$DEST

INCLUDEPATH += $$QTC_SOURCE_DIR/src \
$$QTC_SOURCE_DIR/src/plugins \
C:/qt-creator-2.4.1-src/src/plugins/cppeditor \
$$QTC_SOURCE_DIR/src/plugins/cppeditor \
$$QTC_SOURCE_DIR/src/plugins/coreplugin/ \
$$QTC_SOURCE_DIR/src/plugins/coreplugin/editormanager \
$$QTC_SOURCE_DIR/src/plugins/texteditor/codeassist/ \
$$QTC_SOURCE_DIR/src/libs \
$$QTC_SOURCE_DIR/src/libs/cplusplus \
$$QTC_SOURCE_DIR/src/libs/extensionsystem \
$$QTC_SOURCE_DIR/src/libs/utils \
$$QTC_SOURCE_DIR/src/libs/3rdparty \
$$QTC_SOURCE_DIR/src/libs/3rdparty/cplusplus \
$$QTC_SOURCE_DIR/src/shared \
$$QTC_SOURCE_DIR/src/shared/cplusplus


FORMS += \
dialog.ui \
debugdialog.ui \
extractmethoddialog.ui



the problem in the code: (if I comment this, it builds perfect)

void ExtractMethod::dualscr()
{
Core::Internal::EditorView *w = new Core::Internal::EditorView();
w->show();
}

compile error:

g++ -Wl,-s -mthreads -shared -Wl,--out-implib,release\libRefactoringPlugin.a -o release\RefactoringPlugin.dll object_script.RefactoringPlugin.Release -L"c:\QtSDK1.2\Desktop\Qt\4.8.0\mingw\lib" -L/lib/qtcreator -L/lib/qtcreator/plugins/Nokia -lAggregation -lExtensionSystem -lBotan -lUtils -lCore -lFind -lQtConcurrent -lLocator -lTextEditor -lProjectExplorer -lVCSBase -lCPlusPlus -lLanguageUtils -lCppTools -lCppEditor -LC:/qtcr24/bin -LC:/qtcr24/lib/qtcreator/plugins/Nokia/ -LC:/qtcr24/lib/qtcreator/plugins -LC:/qtcr24/src/plugins/cppeditor/release -lQtGui4 -lQtCore4
Creating library file: release\libRefactoringPlugin.a
mingw32-make.exe[1]: Leaving directory `C:/Users/Bavo/thesis/refactoring/refactoringPlugin'
./release\extractmethod.o:extractmethod.cpp:(.text+0 x21): undefined reference to `Core::Internal::EditorView::EditorView(QWidget*)'

I know it's a linker problem but I just can find the problem. Anybody an idea?

ChrisW67
6th March 2012, 02:51
You are missing a Q_OBJECT macro in the private section one or more classes would be my guess. Alternatively, you have not run qmake since adding it so moc is not being run over the code and the metaobject stuff is not built.

Bavooo
6th March 2012, 11:47
Thx for your answer, but the Q_object macro's are there. Just ran qmake again. No difference. Any other ideas?