|
-
March 11th, 2008, 06:16 AM
#1
calling application class method from plugin
Hello,
I'm having a problem with my plugin platform. I have a main application class, that handles plugin loading and GUI, which is linked into executable. When creating a plugin, I pass a pointer to this class through defined plugin interface. The problem is, that when the plugin is loaded and I call any method of the main class from it, I get unresolved symbol error. I thought that dynamic linking takes care of that, but it doesnt seem to. Do I have to specify some linkage information on every class of the main app? Is there a cross-platform solution to this ( i need to work in win, linux and mac os x)?
Thank you very much
Dalibor
-
March 11th, 2008, 10:31 AM
#2
Re: calling application class method from plugin
It's not a linking problem, in that the function you're calling cannot be found by the linker (dynamically, I'm assuming). Are you sure the function signature is correct (i.e. you're calling the correct function)?
Viggy
-
March 11th, 2008, 11:05 AM
#3
Re: calling application class method from plugin
its a runtime error. The plugin is dyn-linked correctly (e.g error free) to my app, but when the function gets called, i get runtime error telling me the symbol could not be resolved. Yes, I think I'm calling the right function. Declaration of the app class is gathered from its header file, I'm not just guessing which function to call.
dalibor
-
March 11th, 2008, 11:42 AM
#4
Re: calling application class method from plugin
Well, all I can say is that either (a) the function is not exported from your library (if you're running on Windows), or (b) there is a typo in your code.
Without an example, I can't say anything more...
Viggy
-
March 12th, 2008, 11:02 AM
#5
Re: calling application class method from plugin
This one of my classes from the application:
%Project.h%
class Project;
#ifndef _PROJECT_H_
#define _PROJECT_H_
// platform
#include "Platform.h"
// Qt
#include <QFile>
#include <QDir>
#include <QStringList>
#include <QSettings>
class Project
{
friend class Platform;
// consturctors && destructors
private:
Project(QString& projFile);
~Project();
// getters && setters
public:
QString projectFile() const;
QString projectDir() const;
QSettings* config() const;
QString name() const;
QStringList projectType() const;
// data
private:
QString _projectFile;
QString _projectDir;
QSettings* _config;
// project properties
QString _name;
QStringList _projectType;
};
this class gets linked into an executable, along with some other classes
this is a snippet from the plugin:
// slots
void
ProjectsView: rojectOpened(Project* project)
{
_widget->addTopLevelItem(new QTreeWidgetItem(_widget, QStringList(project->name())));
}
it includes Project.h in its associated header file. the calling of name() method fails with this error:
symbol lookup error: /data/School/07-08/Bc/platform/plugins/libbase.so: undefined symbol: _ZNK7Project4nameEv
thanks
dalibor
Last edited by freeagle; March 12th, 2008 at 12:12 PM.
-
March 13th, 2008, 02:54 PM
#6
Re: calling application class method from plugin
just to let you, and maybe the rest of people stuck with similar problem, all I had to do was to declare the method as virtual. Which, if I understand it correctly, placed the entry point of that function into a VTable, which is always only one for a class. So when calling, it gets the entry point from there. Otherwise, the entry point gets statically linked and it doesnt work. Correct me if my understanding of it is wrong please
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|