I just dont get it, why line 22 is failing to compile?
#include <stdexcept>
#include <dlfcn.h>
#include "Library.h"
int main(int argc, char *argv[])
{
try
{
void* libHandle = 0;
libHandle = dlopen("libExpandableTestLibrary.so", RTLD_LAZY);
if(!libHandle)
throw std::logic_error(dlerror());
std::cout << "Libary opened gracefully" << std::endl;
void* fuPtr = 0;
fuPtr = dlsym(libHandle, "createLibrary");
if(!fuPtr)
throw std::logic_error(dlerror());
Library* libInstance = static_cast<Library* ()>(fuPtr)();
// Tutorial: http://www.linuxjournal.com/article/3687
// Tutorial Code: shape *my_shape = static_cast<shape *()>(mkr)();
// Compiler error message: Application.cpp:22:56: error: invalid static_cast from type ‘void*’ to type ‘Library*()’
libInstance->Foo();
dlclose(libHandle);
} catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
}
}
Any help is welcome If you need additional information's just let me know.