I am creating sheared object and opening using dlsysm() but I am getting the following error:
error: invalid conversion from "void*" to "void (*)()"
Here is my code:
#include<iostream>
#include<dlfcn.h>
using namespace std;
int main() {
void (*fnptr)();
void *handle;
handle = dlopen("./libtestshared.so",RTLD_LAZY);
if (!handle) {
cerr << "Cannot open library: " << dlerror() << '\n';
} else {
cout<<"Opening"<<'\n';
}
fnptr = dlsym(handle , "fun");
return 0;
}