1 #include <stdio.h>
2 #include <err.h>
3 #include <dlfcn.h>
4 
5 int
6 main(void)
7 {
8 	void *handle = dlopen("libtest.so", DL_LAZY);
9 	void (*version)(void);
10 
11 	if (handle == NULL)
12 		errx(1, "could not dynamically link libtest");
13 	version = dlsym(handle, "version");
14 	if (version == NULL)
15 		errx(2, "libtest did not define version()");
16 	version();
17 	dlclose(handle);
18 	return 0;
19 }
20