This is a very common issue, and key if you want to write extremely modularized programs.

Look up the functions dlopen, dlsync, and dlclose. Windows has their own functiotns called OpenLibrary, GetProcAddress, and FreeLibrary.

Then you define the interface with extern "C" and the compiler will do the rest for you. You can load a dll, grab its functions, and call them with function pointers.

The only caveat is that if you allocate memory in the library, the library must be the thing that frees it.