in the name of zero

November 11, 2005

dynamic linkage, mixed emotions

Filed under: hermetic studies

i’ve been quite busy recently trying to learn dynamic linkage and so far, things are going quite smoothly. last night, i breathed my first breath of accomplishment when i was finally able to make notation load a module depending on user input. my first useful implementation apart from the usual “hello world”.

my breath of accomplishment was shortlived. for i found these out later. eikke’s blog and this. glib’s gmodule documentation page.

neat! just neat! i guess i have to patch this up now.

static void load_module(const gchar *module_name)
{
	void *module;
	void (*module_function)();
	
	module = dlopen(module_name, RTLD_LAZY);
	if (!module) {
		g_printf(\"dlerror: %s\n\", dlerror());
		return ;
	}
	
	module_function = dlsym(module, \"module_init\");
	if (!module_function) {
		g_printf(\"cannot find entry: module_init()\n\");
		return;
	}
	
	(*module_function)();
	
	dlclose(module);
	return ;
}

Comments »

The URI to TrackBack this entry is: http://gnurbs.blogsome.com/2005/11/11/dynamic-linkage-mixed-emotions/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Get free blog up and running in minutes with Blogsome | Theme designs available here