Public feed #603198

Miscellany

public text v1 · immutable
Raw Edit
·published 2007-07-04 16:27 UTC
rendered paste body
main.c
==========
#include <glib.h>
#include <gmodule.h>
#include <stdio.h>
#include <stdlib.h>

int main (){
	gchar *string = "Hello World!\n";
	printf("%s", string);
	
	gchar *path;
	path = g_module_build_path("", "test");
	printf("The Path: %s\n\n", path);
	
	
	if ( g_module_supported() == TRUE )
	{
		GModule *mod = (GModule *)g_module_open("lib.so", G_MODULE_BIND_LAZY);
		
		void (*foo_func)();
		g_module_symbol(mod, "foo", (gpointer)foo_func);
		
		foo_func();
	}
	
	
	return 0;
}

lib.c
==========
#include <stdio.h>
#include <stdlib.h>

void foo(){
	printf("FOO! \n");
}

int main(){	
	printf("I ran?\n\n");
	
	return 0;
}


Copmiled by:
============
#!/bin/bash
gcc -Wall -fPIC -c lib.c
gcc -shared -o libtest.so lib.o

gcc -Wall -g `pkg-config --cflags glib-2.0 gmodule-2.0 --libs glib-2.0 gmodule-2.0` main.c -o run
chmod +x run