Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 'Undefined interface' when including from /usr/include
Forum Updated to NodeBB v4.3 + New Features

'Undefined interface' when including from /usr/include

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 7.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xarxer
    wrote on last edited by
    #1

    Hello all!

    I have an interface defined like this (minimal example):
    @
    #ifndef IPLUGIN_H_
    #define IPLUGIN_H_

    class IPlugin
    {
    public:
    virtual ~IPlugin() { }
    virtual int getVersion() = 0; //Arbitrary, isn't needed to recreate error
    };

    QT_BEGIN_NAMESPACE
    Q_DECLARE_INTERFACE(IPlugin, "com.xarxer.IPlugin")
    QT_END_NAMESPACE

    #endif
    @

    The IPlugin header file is placed in /usr/include/c++/4.7.2/MyStuff/
    In my .pro file, I do this:
    @
    INCLUDEPATH += /usr/include/c++/4.7.2/MyStuff
    @

    I've also tried variants of INCLUDEPATH such as "-I /usr/include/[...]" etc.

    And in my plugin library (Shared library project) I do this:
    @
    #ifndef MYPLUGIN_H_
    #define MYPLUGIN_H_

    #include <QObject>
    #include <IPlugin> //Tried variants such as <MyStuff/IPlugin>, <MyStuff/IPlugin.h> (with and without .h in the extension on the file etc.)

    class MyPlugin : public QObject, public IPlugin
    {
    Q_OBJECT
    Q_INTERFACES(IPlugin) //This is what generates the error
    //Also tried with and without Q_PLUGIN_METADATA

    public:
    ~MyPlugin() { }
    virtual int getVersion() { return 1; }
    };

    #endif
    @

    But when I compile I get the error "Undefined interface".

    However, if I move the file from /usr/include/[...] to my actual project directory, then the compiler recognizes the interface.
    This really seems like a bug in the compiler or something. Any ideas?

    Thanks in advance!

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      INCLUDEPATH points to the location of the header files and LIBS points to the location of the share library. Make sure that you have set a correct path for LIBS. Read the following wiki article for details and examples of both linking shared library and loading it with QLibrary: "How to create a library with Qt and use it in an application":http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application

      http://anavi.org/

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xarxer
        wrote on last edited by
        #3

        Well, the issue is that the shared library project doesn't compile at all. However, I tried the exact same code on Windows today, and it works fine. I shall experiment a bit with permissions on the include folder as soon as I get home, altough I don't think that's the issue at hand..

        EDIT: Nope, exact same code under Linux does not compile, compiler gives the error 'Undefined interface'. Any help greatly appreciated! :-(

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xarxer
          wrote on last edited by
          #4

          Hello again. I've been experimenting some.

          If I do this in my .pro file:
          @
          INCLUDEPATH += /usr/include/c++/4.7.2/MyStuff
          @

          and this in my header file:
          @
          #include <IPlugin.h>
          @

          It does not compile, and the compiler says "Undefined interface".
          If I omit the INCLUDEPATH, it doesn't compile either, and this really should be omittable since /usr/include is included per default.
          However, if I do this in my .pro file:
          @
          INCLUDEPATH += /usr
          @

          and this in my header file:
          @
          #include <include/c++/4.7.2/MyStuff/IPlugin.h>
          @

          It compiles nicely!
          The former configuration does not generate moc_ files if that matters.

          Again, any help at all in understanding what the problem is is greatly appreciated!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved