PDA

View Full Version : dlopen question.


Guest
December 7th, 2006, 08:11 PM
Just trying out a new backend for compiz-settings, that loads info from the plugin files instead of gconf. But i can't figure out whats wrong with this?


#include <libintl.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <dlfcn.h>
#include <compiz.h>
#include <cairo-xlib-xrender.h>

int
main (int argc, char *argv[])
{

void * handle;
gchar * err;

handle = dlopen ("/usr/lib/compiz/libanotate.so", RTLD_LAZY);
if (!handle) {
/* handle void so print error */
printf ("%s\n", dlerror());
exit(1);
}
return 0;
}



I get the error "/usr/lib/compiz/libannotate.so: undefined symbol: pointerX", but pointerX is defined in compiz.h which has already been include, so I don't really understand the problem? Is it different plugin versions maybe?

lib3d.so loads fine, but all the others fail with similar undefined errors. Anyone know the cause?

mikedee
December 7th, 2006, 08:58 PM
#include <libintl.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <dlfcn.h>
#include <compiz.h>
#include <cairo-xlib-xrender.h>


int lastPointerX = 0;
int lastPointerY = 0;
int pointerX = 0;
int pointerY = 0;

char *programName = "compiz_plugin_loader";

int
main (int argc, char *argv[])
{

void * handle;

handle = dlopen ("/usr/lib/compiz/libannotate.so", RTLD_LAZY);
if (!handle) {
/* handle void so print error */
printf ("%s\n", dlerror());
exit(1);
}
return 0;
}


This code does not produce any output so i assume it loaded correctly.

You need to compile with the -rdynamic gcc flag.

eg.

gcc read.c -I/usr/include/compiz -I/usr/include -I/usr/include/cairo -I/usr/include/startup-notification-1.0 -oread -ldl -rdynamic

Guest
December 7th, 2006, 09:29 PM
Thanks mikdee, its working now, so I need to define these symbols before loading the plugins? How often do these change, am I going to have to release a new version of compiz-settings every time a there is a new release of compiz?

REGION emptyRegion;
REGION infiniteRegion;
GLushort defaultColor[4] = { 0xffff, 0xffff, 0xffff, 0xffff };
Window currentRoot = 0;

int lastPointerX = 0;
int lastPointerY = 0;
int pointerX = 0;
int pointerY = 0;
char *programName = "compiz_plugin_loader";
extern int nWindowTypeString;

char *windowTypeString[] = {
N_("Desktop"),
N_("Dock"),
N_("Toolbar"),
N_("Menu"),
N_("Utility"),
N_("Splash"),
N_("Dialog"),
N_("Normal"),
N_("DropdownMenu"),
N_("PopupMenu"),
N_("Tooltip"),
N_("Notification"),
N_("Combo"),
N_("Dnd"),
N_("ModalDialog"),
N_("Fullscreen"),
N_("Unknown")
};
int nWindowTypeString =
sizeof (windowTypeString) / sizeof (windowTypeString[0]);

mikedee
December 7th, 2006, 11:34 PM
so I need to define these symbols before loading the plugins?

Yes I think so, they are defined normally inside compiz so they have to be redefined by you. Maybe you could post on the mailing list to see if there is anything that can be done to make this process easier for you.

How often do these change, am I going to have to release a new version of compiz-settings every time a there is a new release of compiz?

These do not change very often, I think that as long as you are not reading anything other than functions in the vTable you should be safe. The vTable breakages are between minor revisions eg 0.2 -> 0.3 broke compatability.

You should test against different releases to check when it breaks, but your app compiled against 0.3.2 will in theory work with plugins compiled with 0.3.4 (but not against plugins compiled with 0.2.2)

Guest
December 8th, 2006, 04:07 PM
This way is a seg fault nightmare, I can read basic options from the vtable but if I go any deeper i.e. vt->getDisplayOptions then it seg faults. I would have to define nearly all of the compiz functions (which means it would have to be compiled for a specific version of compiz. I suppose this doesn't matter for libberylsettings because its included in the core.

So this route is not going to work, what i'm thinking now is I wait for the compiz changes to be included. Comon David! or I make some small alterations to the gconf plugin to included the option type and allowed options. First i've got to get compiz compiled from source, which I havn't been able to do yet (can't use git cos i'm behind a proxy)

Guest
December 8th, 2006, 05:40 PM
After a bit more thought I am going to modify gconf, then I can use that as a fall back for when compiz/dbus is not running, without the interface looking any different. I think i'm also going to write a backend that uses libberylsettings as well for all the beryl users.