#include
#include
#include
int main(int argc, char **argv)
{
void *handle;
double (*pow)(double, double);
char *error;
handle = dlopen ("libm.so", RTLD_LAZY);
if (!handle)
{
fprintf (stderr, "%s\n", dlerror());
exit(1);
}
dlerror(); /* Clear any existing error */
pow = dlsym(handle, "pow");
if ((error = dlerror()) != NULL)
{
fprintf (stderr, "%s\n", error);
exit(1);
}
printf ("%f\n", (*pow)(2, 2));
dlclose(handle);
return 0;
}