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. Plugin + QObject: undefined symbol
Forum Updated to NodeBB v4.3 + New Features

Plugin + QObject: undefined symbol

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 666 Views
  • 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.
  • F Offline
    F Offline
    fem_dev
    wrote on last edited by fem_dev
    #1

    I'm writing a set of C-Wrapper functions to my Qt C++ plugins (shared libraries) to enable a pure C call of my library.
    It compiles, loads and works good using QLibrary to load this new files at run-time.

    My problem is that now I would like to use signals and slots between some internal objects of my myLib.
    To enable this, I moved from:

    class myLib
    {
    public:
        myLib();
        ~myLib();
    ...
    }
    
    extern "C" {
        myLib* MYLIB_EXPORT newMyLib(void); // Constructor
    }
    

    To a new form:

    #include <QObject>
    
    class myLib : public QObject
    {
        Q_OBJECT
    public:
        explicit myLib(QObject *parent = nullptr);
        ~myLib();
    ...
    

    Just doing this little movement that I wrote above, when I recompile it and try to load it, I got this run-time load error in my "main application":

    undefined symbol: _ZTV6myLib
    

    If I go back to the original version, without QObject, it works good!

    Why?
    How can I fix it?

    My System:

    • Ubuntu 20.04 x64
    • Qt 5.15.1
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You also have to export your myLib class.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      F 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        You also have to export your myLib class.

        F Offline
        F Offline
        fem_dev
        wrote on last edited by fem_dev
        #3

        @Christian-Ehrlicher said in Plugin + QObject: undefined symbol:

        You also have to export your myLib class.

        I already tried it, but I got the same run-time error on loading this shared library:

        class MYLIB_EXPORT myLib : public QObject
        {
            Q_OBJECT
        public:
            explicit myLib(QObject *parent = nullptr);
            ~myLib();
        ...
        

        And again:

        undefined symbol: _ZTV6myLib
        

        Any ideas?

        jsulmJ 1 Reply Last reply
        0
        • F fem_dev

          @Christian-Ehrlicher said in Plugin + QObject: undefined symbol:

          You also have to export your myLib class.

          I already tried it, but I got the same run-time error on loading this shared library:

          class MYLIB_EXPORT myLib : public QObject
          {
              Q_OBJECT
          public:
              explicit myLib(QObject *parent = nullptr);
              ~myLib();
          ...
          

          And again:

          undefined symbol: _ZTV6myLib
          

          Any ideas?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @fem_dev said in Plugin + QObject: undefined symbol:

          MYLIB_EXPORT

          How is it defined?

          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