C++ Dynamically load arbitrary function from DLL into std::function
问题 How can I load an arbitrary dynamic-link library (dll) function into a std::function object using a single function? For example I would like to compile two functions into a dll: // test.dll int plusFive(int value) { return value + 5; } void printHello() { std::cout << "Hello!" << std::endl; } And load them both at runtime using a single function like this: // main.cc #include <functional> int main() { std::function<int(int)> func1(loadDllFunc("test.dll", "plusFive")); std::function<void()>