Plugin + QObject: undefined symbol
-
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 usingQLibraryto load this new files at run-time.My problem is that now I would like to use
signals and slotsbetween some internal objects of mymyLib.
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: _ZTV6myLibIf 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
-
You also have to export your myLib class.
-
You also have to export your myLib class.
@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: _ZTV6myLibAny ideas?
-
@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: _ZTV6myLibAny ideas?