大家来帮忙看一下这个程序是干什么用的?该如何处理
大家来帮忙看一下这个程序是干什么用的???
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
typedef double (*pfunc)(double);
int main(void)
{
void *handle;
pfunc func;
handle = dlopen("libm.so", RTLD_NOW);
func = dlsym(handle, "sqrt");
if (handle == NULL || func == NULL) {
printf("Open so failed: %s.\n", dlerror());
exit(EXIT_FAILURE);
}
printf("add = %f\n", func(2));
dlclose(handle);
return 0;
}
------解决方案--------------------
从libm.so中获取函数sqrt的入口地址,然后调用sqrt(2),相当于开平方
------解决方案--------------------
------解决方案--------------------
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
typedef double (*pfunc)(double);
int main(void)
{
void *handle;
pfunc func;
handle = dlopen("libm.so", RTLD_NOW);
func = dlsym(handle, "sqrt");
if (handle == NULL || func == NULL) {
printf("Open so failed: %s.\n", dlerror());
exit(EXIT_FAILURE);
}
printf("add = %f\n", func(2));
dlclose(handle);
return 0;
}
------解决方案--------------------
从libm.so中获取函数sqrt的入口地址,然后调用sqrt(2),相当于开平方
------解决方案--------------------
------解决方案--------------------