Reputation: 3121
I have a problem with passing a object to Qt Plugin and when trying to get its member using const member function i get symbol lookup error. Example:
This is inside Qt application:
class A{
int a,b,c;
};
class B{
public:
const QList<A*>* a() const { return m_a; }
private:
QList<A*>* m_a;
};
class C{
public:
const B* b() const { return m_b; }
private:
B* m_b;
};
This is inside QtPlugin:
plugin.h
#include "a.h"
#include "b.h"
#include "c.h"
//....
plugin.cpp
void Plugin::somefunc(C* c)
{
qDebug() << c->b()->a()->count();
}
If I call from Qt application somefunc() of a plugin I get symbol lookup error:
symbol lookup error ... plugin.so undefined symbol _ZNK5b6a
but if I put B and C class members into public domain it works using:
qDebug() << c->m_b->m_a->count();
Did anyone have similar problem or knows how to solve this? Thanks.
Upvotes: 1
Views: 780
Reputation: 3121
There are two solutions to this "problem".
I haven't found similar question on web, and thus putting this answer. Maybe question was fuzzy, sorry about that. Thanks for answer. This answer is for any future reference.
Upvotes: 1
Reputation: 31647
Class members are private by default. B::a()
and C::b()
are private. To be able to call these member functions from Plugin::somefunc()
you need to make them public explicitly.
Upvotes: 1