#include "foo.hpp" #include #include #include typedef Foo *FooConstructor(); int main(int argc, char **argv) { if (argc!=2) { std::cerr << "usage: " << argv[0] << " " << std::endl; return 1; } void* handle = dlopen(argv[1], RTLD_LAZY | RTLD_LOCAL); if (!handle) { return 2; } FooConstructor *constructor = (FooConstructor*) dlsym(handle, "construct"); if (!constructor) { dlclose(handle); return 3; } Foo *foo = constructor(); foo->msg(); }