Re: g_module...: module calls function of core applicatioin



On Sun, 2005-10-30 at 19:24 +0100, David Necas (Yeti) wrote:
On Sun, Oct 30, 2005 at 05:43:21PM +0100, Tobias Kipfelsberger wrote:
I have a plugin which is registered and loaded with the g_module functions.
So far so good everything works find.
But how can i let the modul access a function of the coreapplication?

Example:
in CoreApplication.h:

G_MODULE_EXPORT void 
setCoreMenuAppbarText (const gchar* text)
{}

in plugin.c:

#include "CoreApplication.h"
void
xyz ()
{
     setCoreMenuAppbarText("test");
}

as i execute the programm... i always get a undefined symbol error.

You have to link the program with -export-dynamic (either as
ld option, or libtool link option if you use libtool).


This is needed because by default the symbols defined in the main app
are not made visible to the plugins. And the OP should be warned there
is a good reason for the default.

If badly written plugins can call to the main application code they can
easily make it look to the user as if *your* app code is broken. You
should be prepared to handle the resulting support requests. Note, for
example, the way the linux kernel team refuse to support bug reports
from anyone running a "tainted" kernel.

If there is a well defined API you do want plugins to access, you can
place the relevant code into a shared object of its own. Then you don't
need to do anything special to protect it from Murphy's Law, since only
the parts deliberately exposed can be accessed easily.

HTH

Simon Bone




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]