Dynamically calling external libraries.

Adam D. Ruppe destructionator at gmail.com
Wed Feb 26 06:41:01 PST 2014


You'd do it the same way you do in C. On Windows, call 
LoadLibrary, FreeLibrary, and GetProcAddress or the COM 
functions. On Linux, the family of functions is dlopen, dlsym, 
and dlclose.

Knowing the types to pass the functions is gonna be tricky and 
this needs to be right to avoid crashes. On Windows with 
scripting language, this is often done through COM automation: 
the IDispatch interface. With regular C functions, you really 
just have to know the prototypes ahead of time... it won't be 
fully dynamic, you load the library at run time but know how to 
use it at compile time.


More information about the Digitalmars-d-learn mailing list