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. Error Building interface in Qt 5.1
Qt 6.11 is out! See what's new in the release blog

Error Building interface in Qt 5.1

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.7k 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.
  • A Offline
    A Offline
    ad5xj
    wrote on last edited by
    #1

    I am attempting to build an interface and implementation in Qt 5.1

    My interface class foo.hpp
    @
    #ifndef FOO_HPP
    #define FOO_HPP
    #include <QtCore/QtPlugin>

    class Foo // defined interface to my implementation base class
    {

    public:
    // my virtual interface functions
    virtual void init();
    };
    #define Foo_iid "com.myproj.Foo"
    Q_DECLARE_INTERFACE(Foo, Foo_iid)
    @

    my base class definition FooBase.h
    @
    #include "foo.h"

    class FooBase : public QObject, public Foo
    {
    // Implementation of the Foo interface class
    Q_OBJECT
    Q_INTERFACES(Foo)

    public:
    explicit FooBase(QObject *parent=0);

    void init();
    

    };
    @

    my implementation base code foobase.cpp
    @
    FooBase::FooBase(QObject *parent) : QObject(parent), Foo()
    {
    //
    }

    void init()
    {
    // code to initialize foo
    }
    @

    my project file foo.pro
    @
    TEMPLATE = lib
    TARGET = foo
    DESTDIR = ../lib

    QT += core gui widgets printsupport network
    CONFIG += qt thread exceptions resources qwt shared
    unix: { CONFIG += x11 }
    windows: { CONFIG += windows }

    OBJECTS_DIR = obj
    MOC_DIR = moc
    RCC_DIR = rcc

    HEADERS += foo.hpp foobase.hpp
    SOURCES += foobase.cpp
    if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
    mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug
    win32:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)d
    }
    @

    The compile in QtCreator returns only 3 errors that are rather cryptic and need to know what it means and what to look for -
    errno: TLS definition in /lib/i386-linux-gnu/libc.so.6 section .tbss mismatches non-TLS definition in obj/winmorbase.o section .bss
    /lib/i386-linux-gnu/libc.so.6:-1: error: could not read symbols: Bad value
    error: collect2: error: ld returned 1 exit status

    The last error line I understand as I have seen in numerous times. It is the first two that have me stumped.

    Can anyone help?

    Ken AD5XJ

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you are defining an interface your init() function should be pure virtual

      @virtual void init() = 0;@

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ad5xj
        wrote on last edited by
        #3

        I am missing something. The foo.h interface definition does have the pure virtual function as virtual void init(). The only thing different is that it is not initialized in the same way.

        Will this illicit the error I am seeing?

        Ken AD5XJ

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Not sure if you missed declaration

          @void init()
          {
          // code to initialize foo
          }@

          should be

          @void FooBase::init()
          {
          // code to initialize foo
          }@

          not sure if you are missing that part or not in your project?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ad5xj
            wrote on last edited by
            #5

            I found a typo to cause the error mentioned. Now there are a whole bunch of new vtable errors for some reason. Checking.

            Ken AD5XJ

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              vtable errors a generally there when adding or removing Q_OBJECT from a class and rebuilding without running qmake

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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