I'm trying to access function from dynamic library, that instantiates an instance of Person, and returns pointer to it as void pointer. The program then has to cast the void pointer to a Person, using a reinterpret_cast. But, I'm getting an error: error: ‘void*’ is not a pointer-to-object type.
Here is the code:
function from library:
void* loadPerson (void) {
return reinterpret_cast<void*>(new Person);
}
main.cpp:
void* loadPerson = dlsym(lib_handle, "loadPerson");
void* person_vp = (*loadPerson)();
Person* person = reinterpret_cast<Person*>(person_vp);
if (dlerror() != NULL)
cout<<"Library init error."<<endl;
else {
//...
Thanks!