#include <stdio.h>
#include <dlfcn.h>

main()
{
	void	*open_handle,			/* library handle */
		(*access_handle)();		/* function handle */
	/*
	 * Load and get a handle on our shared object.
	 */
	open_handle = dlopen("./libshared.so.1", RTLD_LAZY);
	if (open_handle == NULL) {
		fprintf(stderr, "dlopen failed: %s\n",
			dlerror());
		exit(1);
	}
	/*
	 * Obtain the symbol we wish to access (pnum).
	 */
	access_handle = (void (*)())dlsym(open_handle, "pnum");
	if (access_handle == NULL) {
		fprintf(stderr, "dlsym failed: %s\n",
			dlerror());
		exit(1);
	}
	/*
	 * Use the handle to call our function.
	 */
	(*access_handle)(10);
	/*
	 * Now, remove the shared object, and terminate.
	 */
	if (dlclose(open_handle) != 0) {
		fprintf(stderr, "dlclose failed: %s\n",
			dlerror());
		exit (1);
	}
}
