#include <stdio.h>
#include <dlfcn.h>
void main(void)
{
void *handle;
double (*cosine)(double);
char *error;
handle = dlopen("/usr/lib/libm.so", RTLD_LAZY);
if (! handle) {
fprintf(stderr, "%s\n", dlerror());
exit(1);
}
cosine= dlsym(handle, "cos");
if ((error = dlerror()) != NULL) {
fprintf(stderr, "%s\n", error);
exit(1);
}
printf("%f\n", (*cosine)(2.0));
dlclose(handle);
}