Results 1 to 12 of 12

Thread: "Undefined reference to" in QtCreator plugin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: "Undefined reference to" in QtCreator plugin

    Show the code, it's almost impossible to help without seeing it.

  2. #2
    Join Date
    Nov 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: "Undefined reference to" in QtCreator plugin

    LoggerPlugin.h
    Qt Code:
    1. #ifndef LOGGERPLUGIN_H
    2. #define LOGGERPLUGIN_H
    3. #include <QTextStream>
    4. #include <QtPlugin>
    5. #include <QStringList>
    6. #include <QMessageBox>
    7. #include <QString>
    8. #include <QtCore/QDebug>
    9. #include <Logger/xmlproxy.h>
    10.  
    11.  
    12.  
    13.  
    14. class LoggerPlugin : public ExtensionSystem::IPlugin
    15. {
    16.  
    17. private:
    18. QString lookupName(int id);
    19. int lookupID(QString name);
    20.  
    21. public:
    22.  
    23. XMLLoggerPlugin();
    24. ~XMLLoggerPlugin();
    25. void extensionsInitialized();
    26. bool initialize(const QStringList & arguments, QString * errorString);
    27. void shutdown();
    28.  
    29. // this is the method called by CppEditor. It just instantiate my proxy object.
    30. static void register(QString name, QString filename, QString type){
    31. XMLProxy pr(name, filename, type);
    32. }
    33. };
    34. #endif // LOGGERPLUGIN_H
    To copy to clipboard, switch view to plain text mode 

    LoggerPlugin.cpp then contains the implementation of the initialize and shutdown methods, but nothing tricky just clean-up code.

    XMLProxy.h
    Qt Code:
    1. #ifndef XMLPROXY_H
    2. #define XMLPROXY_H
    3. class XMLProxy
    4. {
    5. public:
    6. XMLProxy();
    7. ~XMLProxy();
    8. XMLProxy(QString name, QString filename, QString type);
    9. void serializeXML();
    10. QString _name, _filename, _type;
    11. };
    12.  
    13. #endif // XMLPROXY_H
    To copy to clipboard, switch view to plain text mode 

    and the class implementation
    XMLProxy.cpp
    Qt Code:
    1. #include <QDateTime>
    2. #include <QFile>
    3. #include <QXmlStreamWriter>
    4. #include <QDate>
    5. #include <extensionsystem/iplugin.h>
    6. #include <QtXml/QDomDocument>
    7. #include <QtXml/QDomElement>
    8. #include <QtXml/QDomText>
    9. #include "xmlproxy.h"
    10. XMLProxy::XMLProxy(){}
    11. XMLProxy::XMLProxy(QString name, QString filename, QString type){
    12. this->_name=name;
    13. this->_filename=namefilename;
    14. this->_type=type;
    15. }
    16.  
    17. XMLProxy::serializeXML(){
    18. //stub of the method to serialize a XMLProxy to a XML file
    19. QFile file("Logfile.xml");
    20. QDomDocument doc("Events");
    21. QDomElement ev = doc.createElement("event");
    22. QDomElement typeNode = doc.createElement("type");
    23. QDomText typeTxt = doc.createTextNode(this->_type);
    24. typeNode.appendChild(typeTxt);
    25. ev.appendChild(typeNode);
    26. //...to be cont´d
    27. }
    To copy to clipboard, switch view to plain text mode 

    it´s not working like this but if I move the code from XMLProxy.cpp to XMLProxy.h it works
    To compile I do "qmake ..\qtcreator.pro -recursive CONFIG+=debug QT+=xml" from the build directory of qtcreator folder and then, from the same dir, "mingw32-make debug"

    Thank you for any help

  3. #3
    Join Date
    Nov 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: "Undefined reference to" in QtCreator plugin

    That´s the output after executing mingw32-make

    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
    oc -Wl,-s -mthreads -Wl -shared -Wl,--out-implib,c:\ProjectII\qt-creator-win\bui
    ld\lib\qtcreator\plugins\Nokia\libTextEditor.a -o ..\..\..\lib\qtcreator\plugins
    \Nokia\TextEditor.dll object_script.TextEditor.Release -L"c:\Qt\2010.05\qt\lib"
    -LC:/ProjectII/qt-creator-win/build/lib/qtcreator -LC:/ProjectII/qt-creator-win
    /build/lib/qtcreator/plugins/Nokia -lUtils -lAggregation -lExtensionSystem -lBot
    an -lNet7ssh -lCore -lFind -lQtConcurrent -lLocator -LC:/ProjectII/qt-creator-wi
    n/src/plugins/texteditor/../../../lib/qtcreator/plugins/Nokia -lLogger -LC:/P
    rojectII/qt-creator-win/build/src/plugins/texteditor/../../../lib/qtcreator/plug
    ins/Nokia -lLogger -lQtXml4 -lQtGui4 -lQtCore4
    Creating library file: c:\ProjectII\qt-creator-win\build\lib\qtcreator\plugins\N
    okia\libTextEditor.a
    ./release\basetexteditor.o:basetexteditor.cpp.text+0x13cfc): undefined referen
    ce to `XMLProxy::XMLProxy(QString, QString, QString)'
    collect2: ld returned 1 exit status
    mingw32-make[4]: *** [..\..\..\lib\qtcreator\plugins\Nokia\TextEditor.dl l] Error
    1
    mingw32-make[4]: Leaving directory `C:/ProjectII/qt-creator-win/build/src/plugin
    s/texteditor'
    mingw32-make[3]: *** [release] Error 2
    mingw32-make[3]: Leaving directory `C:/ProjectII/qt-creator-win/build/src/plugin
    s/texteditor'
    mingw32-make[2]: *** [sub-texteditor-sub_Release] Error 2
    mingw32-make[2]: Leaving directory `C:/ProjectII/qt-creator-win/build/src/plugin
    s'
    mingw32-make[1]: *** [sub-plugins-sub_Release_ordered] Error 2
    mingw32-make[1]: Leaving directory `C:/ProjectII/qt-creator-win/build/src'
    mingw32-make: *** [sub-src-sub_Release_ordered] Error 2


    while this is my .pro file

    Qt Code:
    1. TEMPLATE = lib
    2. TARGET = Logger
    3. include(../../qtcreatorplugin.pri)
    4. DESTDIR = $$IDE_PLUGIN_PATH/Nokia
    5. PROVIDER = Nokia
    6. include(../../plugins/coreplugin/coreplugin.pri)
    7. HEADERS += LoggerPlugin.h \
    8. xmlproxy.h
    9. SOURCES += LoggerPlugin.cpp \
    10. xmlproxy.cpp
    11. OTHER_FILES += Logger.pluginspec
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: "Undefined reference to" in QtCreator plugin

    I would have thought you'd get an undefined reference to XMLProxy::~XMLProxy()
    I can't see the function for that one.

  5. #5
    Join Date
    Nov 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: "Undefined reference to" in QtCreator plugin

    I put it actually in one of my tries but I still got the same error.
    But still if I move all the code into the .h file it works

Similar Threads

  1. Replies: 2
    Last Post: 27th August 2011, 12:59
  2. Replies: 1
    Last Post: 19th February 2011, 13:32
  3. Replies: 2
    Last Post: 23rd June 2010, 22:00
  4. "Undefined reference to" error
    By f.tristano in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2009, 10:00
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.