Loading shared libraries and classes dynamically at runtime. - Poco
Loading shared libraries and classes dynamically at runtime. - Poco
Loading shared libraries and classes dynamically at runtime. - Poco
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
LibraryLoaderTest.cpp<br />
#include "<strong>Poco</strong>/SharedLibrary.h"<br />
using <strong>Poco</strong>::SharedLibrary;<br />
typedef void (*HelloFunc)(); // function pointer type<br />
int main(int argc, char** argv)<br />
{<br />
std::string p<strong>at</strong>h("TestLibrary");<br />
p<strong>at</strong>h.append(SharedLibrary::suffix()); // adds ".dll" or ".so"<br />
SharedLibrary library(p<strong>at</strong>h); // will also load the library<br />
HelloFunc func = (HelloFunc) library.getSymbol("hello");<br />
func();<br />
library.unload();<br />
}<br />
return 0;