Results 1 to 2 of 2

Thread: QtPlugin and undefined symbol

  1. #1
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtPlugin and undefined symbol

    FilePluginInterface.h
    Qt Code:
    1. #ifndef FILEPLUGININTERFACE_H
    2. #define FILEPLUGININTERFACE_H
    3.  
    4. #include "Geocache.h"
    5.  
    6. #include <QtPlugin>
    7. #include <QIODevice>
    8. #include <QString>
    9. #include <QList>
    10.  
    11. class FilePluginInterface {
    12. public:
    13. virtual ~FilePluginInterface() {}
    14.  
    15. virtual const char *getName() const throw() = 0;
    16. virtual const char *getVersion() const throw() = 0;
    17. virtual const char *getAuthor() const throw() = 0;
    18. virtual const char *getAuthorEmail() const throw() = 0;
    19. virtual bool isValid(QIODevice *source) = 0;
    20.  
    21. virtual QList<Geocache*> getAll(QIODevice *source) = 0;
    22. };
    23.  
    24. Q_DECLARE_INTERFACE(FilePluginInterface, "com.Something.Plugins.FilePlugin/1")
    25.  
    26. #endif // FILEPLUGININTERFACE_H
    To copy to clipboard, switch view to plain text mode 

    GeocachingComGpx.cpp
    Qt Code:
    1. #include "../../../src/FilePluginInterface.h"
    2.  
    3. class GeocachingComGpx : public QObject, public FilePluginInterface {
    4. Q_OBJECT
    5. Q_INTERFACES(FilePluginInterface)
    6.  
    7. public:
    8. const char *getName() const throw();
    9. const char *getVersion() const throw();
    10. const char *getAuthor() const throw();
    11. const char *getAuthorEmail() const throw();
    12.  
    13. bool isValid(QIODevice *source);
    14.  
    15. QList<Geocache*> getAll(QIODevice *source);
    16. };
    17.  
    18. const char *GeocachingComGpx::getName() const throw()
    19. {
    20. return "Geocaching.com GPX Files";
    21. }
    22.  
    23. const char *GeocachingComGpx::getVersion() const throw()
    24. {
    25. return "0.1.0";
    26. }
    27.  
    28. const char *GeocachingComGpx::getAuthor() const throw()
    29. {
    30. return "James Marshall Hendrix";
    31. }
    32.  
    33. const char *GeocachingComGpx::getAuthorEmail() const throw()
    34. {
    35. return "jimi@hendrix.com";
    36. }
    37.  
    38. bool GeocachingComGpx::isValid(QIODevice *source)
    39. {
    40. Q_UNUSED(source);
    41. return true;
    42. }
    43.  
    44. QList<Geocache*> GeocachingComGpx::getAll(QIODevice *source)
    45. {
    46. Q_UNUSED(source);
    47. return QList<Geocache*>();
    48. }
    49.  
    50. Q_EXPORT_PLUGIN2(GeocachingComGpx, GeocachingComGpx);
    To copy to clipboard, switch view to plain text mode 

    GeocachingComGpx.pro
    Qt Code:
    1. NAME = GeocachingComGpx
    2. VERSION = 0.1.0
    3. HEADERS += ../../../src/FilePluginInterface.h
    4. SOURCES += GeocachingComGpx.cpp
    5.  
    6. TEMPLATE = lib
    7. TARGET = $${NAME}
    8. DESTDIR = ../../../bin/plugins/file/
    9. DEPENDPATH += $$PWD
    10. INCLUDEPATH += $$PWD
    11. CONFIG += plugin
    12.  
    13. target.path = /usr/share/something/plugins/file/
    14.  
    15. INSTALLS += target
    To copy to clipboard, switch view to plain text mode 

    And when I'm trying to load a plugin:

    Qt Code:
    1. QStringList files = path.entryList(QDir::Files);
    2.  
    3. for (QStringList::iterator it2 = files.begin(); it2 != files.end(); it2++) {
    4. QPluginLoader pluginLoader(path.absoluteFilePath(*it2));
    5. QObject *plugin = pluginLoader.instance();
    6.  
    7. if (plugin) {
    8. filePlugins.append(qobject_cast<FilePluginInterface*>(plugin));
    9. qDebug() << "Loaded plugin" << filePlugins.last()->getName()
    10. << filePlugins.last()->getVersion();
    11. } else {
    12. qDebug() << pluginLoader.errorString();
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    pluginLoader.errorString() gives me

    Qt Code:
    1. /some/nice/path/bin/plugins/file/libGeocachingComGpx.so: undefined symbol: _ZTV16GeocachingComGpx
    To copy to clipboard, switch view to plain text mode 

    _ZTV16GeocachingComGpx seems to be the symbol of my plugin's class (I looked into binary, methods symbols are prepended by it). Why it's missing from the binary? And if it's not, what's going on then?

    Thanks for your time

  2. #2
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: QtPlugin and undefined symbol

    Ok, that was lame. I've just moved class declaration to a header file, and added it to HEADERS in .pro. Now everything works. Q_OBJECT macro just doesn't like source files.

Similar Threads

  1. Problem using QtPlugin
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 27th March 2008, 07:49
  2. relink qtplugin to QtGui && QtCore
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2007, 13:44
  3. QtPlugin compile issue
    By croland in forum Qt Programming
    Replies: 2
    Last Post: 25th May 2007, 17:37
  4. MySql and QtPlugin
    By darksaga in forum Installation and Deployment
    Replies: 6
    Last Post: 15th May 2007, 11:09
  5. undefined symbol in library
    By quickNitin in forum General Programming
    Replies: 1
    Last Post: 16th November 2006, 11:50

Tags for this Thread

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.