Results 1 to 3 of 3

Thread: linker problem in plugin, undefined reference to `Core::....

  1. #1
    Join Date
    Oct 2011
    Posts
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default linker problem in plugin, undefined reference to `Core::....

    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:

    Qt Code:
    1. CppEditor::Internal::CPPEditorWidget *testccped = qobject_cast<CppEditor::Internal::CPPEditorWidget *>(textEditor->widget());
    To copy to clipboard, switch view to plain text mode 

    error:
    Qt Code:
    1. ./release\extractmethod.o:extractmethod.cpp:(.text+0x3f7): undefined reference to 'CppEditor::Internal::CPPEditorWidget::staticMetaObject'
    To copy to clipboard, switch view to plain text mode 

    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)
    Qt Code:
    1. TARGET = RefactoringPlugin
    2. CONFIG += release
    3. TEMPLATE = lib
    4.  
    5. DEFINES += REFACTORINGPLUGIN_LIBRARY
    6.  
    7.  
    8. # RefactoringPlugin files
    9.  
    10. SOURCES += refactoringpluginplugin.cpp \
    11. methoderenamedialog.cpp \
    12. dialog.cpp \
    13. extractmethod.cpp \
    14. debugdialog.cpp \
    15. extractmethoddialog.cpp \
    16. gensetget.cpp
    17.  
    18.  
    19. HEADERS += refactoringpluginplugin.h\
    20. refactoringplugin_global.h\
    21. refactoringpluginconstants.h \
    22. methoderenamedialog.h \
    23. dialog.h \
    24. extractmethod.h\
    25. debugdialog.h \
    26. extractmethoddialog.h \
    27. gensetget.h
    28.  
    29.  
    30. OTHER_FILES = RefactoringPlugin.pluginspec
    31.  
    32.  
    33. # Qt Creator linking
    34. QTC_SOURCE_DIR = C:/qt-creator-2.4.1-src
    35. IDE_SOURCE_TREE = $$QTC_SOURCE_DIR
    36. QTC_BUILD_DIR = C:/qtcr24
    37.  
    38. include($$QTC_SOURCE_DIR/src/qtcreatorplugin.pri)
    39. include($$QTC_SOURCE_DIR/src/plugins/coreplugin/coreplugin.pri)
    40. include($$QTC_SOURCE_DIR/src/plugins/texteditor/texteditor.pri)
    41. include($$QTC_SOURCE_DIR/src/plugins/coreplugin/coreplugin.pri)
    42. include($$QTC_SOURCE_DIR/src/plugins/vcsbase/vcsbase.pri)
    43. include($$QTC_SOURCE_DIR/src/libs/utils/utils.pri)
    44. include($$QTC_SOURCE_DIR/src/libs/cplusplus/cplusplus.pri)
    45. include($$QTC_SOURCE_DIR/src/plugins/cppeditor/cppeditor_dependencies.pri)
    46. include($$IDE_SOURCE_TREE/src/plugins/coreplugin/coreplugin.pri )
    47. include($$IDE_SOURCE_TREE/src/plugins/texteditor/texteditor.pri )
    48. include($$QTC_SOURCE_DIR/src/plugins/cppeditor/cppeditor.pri)
    49. include($$QTC_SOURCE_DIR/src/plugins/cpptools/cpptools.pri)
    50. include($$QTC_SOURCE_DIR/src/plugins/locator/locator.pri)
    51.  
    52. LIBS += -LC:/qtcr24/bin \
    53. -LC:/qtcr24/lib/qtcreator/plugins/Nokia/ \
    54. -LC:/qtcr24/lib/qtcreator/plugins \
    55. -LC:/qtcr24/src/plugins/cppeditor/release
    56.  
    57.  
    58.  
    59.  
    60. DESTDIR = $$DEST
    61.  
    62. INCLUDEPATH += $$QTC_SOURCE_DIR/src \
    63. $$QTC_SOURCE_DIR/src/plugins \
    64. C:/qt-creator-2.4.1-src/src/plugins/cppeditor \
    65. $$QTC_SOURCE_DIR/src/plugins/cppeditor \
    66. $$QTC_SOURCE_DIR/src/plugins/coreplugin/ \
    67. $$QTC_SOURCE_DIR/src/plugins/coreplugin/editormanager \
    68. $$QTC_SOURCE_DIR/src/plugins/texteditor/codeassist/ \
    69. $$QTC_SOURCE_DIR/src/libs \
    70. $$QTC_SOURCE_DIR/src/libs/cplusplus \
    71. $$QTC_SOURCE_DIR/src/libs/extensionsystem \
    72. $$QTC_SOURCE_DIR/src/libs/utils \
    73. $$QTC_SOURCE_DIR/src/libs/3rdparty \
    74. $$QTC_SOURCE_DIR/src/libs/3rdparty/cplusplus \
    75. $$QTC_SOURCE_DIR/src/shared \
    76. $$QTC_SOURCE_DIR/src/shared/cplusplus
    77.  
    78.  
    79. FORMS += \
    80. dialog.ui \
    81. debugdialog.ui \
    82. extractmethoddialog.ui
    To copy to clipboard, switch view to plain text mode 

    the problem in the code: (if I comment this, it builds perfect)
    Qt Code:
    1. void ExtractMethod::dualscr()
    2. {
    3. Core::Internal::EditorView *w = new Core::Internal::EditorView();
    4. w->show();
    5. }
    To copy to clipboard, switch view to plain text mode 
    compile error:
    Qt Code:
    1. 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
    2. Creating library file: release\libRefactoringPlugin.a
    3. mingw32-make.exe[1]: Leaving directory `C:/Users/Bavo/thesis/refactoring/refactoringPlugin'
    4. [COLOR="#FF0000"]./release\extractmethod.o:extractmethod.cpp:(.text+0x21): undefined reference to `Core::Internal::EditorView::EditorView(QWidget*)[/COLOR]'
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: linker problem in plugin, undefined reference to `Core::....

    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.

  3. #3
    Join Date
    Oct 2011
    Posts
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: linker problem in plugin, undefined reference to `Core::....

    Thx for your answer, but the Q_object macro's are there. Just ran qmake again. No difference. Any other ideas?

Similar Threads

  1. Undefined reference problem
    By deepa in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2011, 11:48
  2. Replies: 11
    Last Post: 20th March 2011, 08:38
  3. Plugin compiler error: undefined reference
    By FinderCheng in forum Qt Programming
    Replies: 8
    Last Post: 1st May 2010, 16:49
  4. Problem: Undefined reference
    By stiank81 in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2006, 14:17
  5. Replies: 5
    Last Post: 14th February 2006, 23:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.