[Kde-finance-apps] [kde-finance-apps] Qt Plugins + CMake linking help?

Brian Cappello briancappello at gmail.com
Sun Jun 27 22:44:04 CEST 2010


Hi everybody,
I've been trying to get plugins working, but to no avail. To start small
extremely small, here's a simple plugin I'm trying to make. I keep getting
linker errors, I was hoping maybe somebody could pick up on something I'm
missing? Below are the files and the error I'm getting. I've already wasted
a fair bit of time on this, so, what are people's opinions on maybe
scrapping the idea of plugins in the short term? Originally I figured it
best to get them working early, but at this point, I feel it's seriously
beginning to hinder progress...

Thanks in advance for any input :)

***** interfaces.h ******************************
class KeysInterface
{
  public:
    virtual ~KeysInterface();
    virtual QStringList keys() const = 0;
};
Q_DECLARE_INTERFACE( KeysInterface,
             "org.kde.quotebackend.KeysInterface/1.0" );

***** testplugin.h *****************************
#ifndef TEST_PLUGIN_H
#define TEST_PLUGIN_H
#include <QObject>
#include <QStringList>
#include "interfaces.h"
class KeysInterface;

class TestPlugin : public QObject, public KeysInterface
{
  Q_OBJECT
  Q_INTERFACES(KeysInterface)

  public:
    virtual ~TestPlugin() {}

    QStringList keys() const;
};
#endif

***** testplugin.cpp ***********************
#include "testplugin.h"
QStringList TestPlugin::keys() const
{
  return QStringList() << "This" << "Plugin" << "Appears" << "To" << "Work";
}
Q_EXPORT_PLUGIN2(testplugin, TestPlugin);

**** cmake ******************************
cmake_minimum_required( VERSION 2.6 )
PROJECT( quotebackend )

FIND_PACKAGE( Qt4 REQUIRED )
SET( QT_USE_QTSQL true )
SET( QT_USE_QTDBUS true )
SET( QT_USE_QTNETWORK true )
SET( QT_USE_QTSCRIPT true )

INCLUDE( ${QT_USE_FILE} )
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
ADD_DEFINITIONS( -DQT_PLUGIN )
ADD_DEFINITIONS( -DQT_SHARED )
INCLUDE_DIRECTORIES( ${QT_INCUDE_DIR}
             ${QT_QTNETWORK_INCLUDE_DIR}
             ${QDBUS_INCLUDE_DIRS}
             ${QT_QTSQL_INCLUDE_DIR} )

SET( backend_SRCs
     main.cpp
     backend.cpp
     symbolmanager.cpp
     statsmanager.cpp
     downloader.cpp
     testplugin.cpp
      )

# set all QObjects to have their MOC files generated
SET( backend_MOC_Headers
     plugininterfaces.h
     testplugin.h
     backend.h
     symbolmanager.h
     statsmanager.h
     downloader.h
      )

QT4_WRAP_CPP( backend_MOC_SRCs ${backend_MOC_Headers} )

# setup cmake to automatically generate dbus adaptor objects
QT4_ADD_DBUS_ADAPTOR( backend_SRCs org.kde.quotebackend.symbolmanager.xml
symbolmanager.h SymbolManager )
QT4_ADD_DBUS_ADAPTOR( backend_SRCs org.kde.quotebackend.statsmanager.xml
statsmanager.h StatsManager )

#SET( PLUGIN_SRCS
 #    testplugin.cpp
#    )

#SET( PLUGIN_MOC_HEADERS
   #  testplugin.h
  #   plugininterfaces.h
 #   )

#QT4_WRAP_CPP( PLUGIN_MOC_SRCS ${PLUGIN_MOC_HEADERS} )
#ADD_LIBRARY(testplugin SHARED ${PLUGIN_SRCS} ${PLUGIN_MOC_SRCS}) # /me
thinks this is the problem? I sniped this line from
# a project i found using qt, cmake, and plugins but yea, it doesn't work
ADD_LIBRARY(testplugin SHARED ${backend_SRCs} ${backend_MOC_SRCs}) #same
error for the above line and this one. changing SHARED to MODULE doesn't
work either

TARGET_LINK_LIBRARIES( testplugin ${DEFAULT_PLUGIN_SUBDIR}) #same error with
or without this line

ADD_EXECUTABLE( quotebackend ${backend_SRCs} ${backend_MOC_SRCs} )
TARGET_LINK_LIBRARIES( quotebackend ${QT_LIBRARIES} )
INSTALL( TARGETS quotebackend ${INSTALL_TARGETS_DEFAULT_ARGS} DESTINATION
bin )

# install the adaptor xml description files so clients can build against
them (is --prefix/interfaces the correct place for these?)
FILE(GLOB adaptorfiles "${CMAKE_CURRENT_SOURCE_DIR}/*.xml")
INSTALL(FILES ${adaptorfiles} DESTINATION interfaces)

***** error **************
Linking CXX executable quotebackend
CMakeFiles/quotebackend.dir/moc_testplugin.cxx.o: In function
`~TestPlugin':

/home/brian/quotebackend/build/backend/../../backend/testplugin.h:19:
undefined reference to `KeysInterface::~KeysInterface()'
/home/brian/quotebackend/build/backend/../../backend/testplugin.h:19:
undefined reference to `KeysInterface::~KeysInterface()'
collect2: ld returned 1 exit status
make[2]: *** [backend/quotebackend] Error 1
make[1]: *** [backend/CMakeFiles/quotebackend.dir/all] Error 2
make: *** [all] Error 2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-finance-apps/attachments/20100627/332e5e5d/attachment.htm 


More information about the Kde-finance-apps mailing list