I have an application which I have managed to keep reasonably cross-platform between windows and Linux. Cmake and Boost have been helpful in this endeavor.
The time has come to link to a .dll which has been written for windows. If I can put off the conversion of the dynamically linked library it would be a good thing. Other windows applications connect up to this library like this:
HINSTANCE dll;
dll = LoadLibraryA(filename);
//...
libFuncPtr = (libFuncPtr)GetProcAddress(dll, "libFunc");
I’d like to know if there are generic analogs to these functions or is it time to start dropping in my system specific preprocessor directives? The Current Priority for Developemt is Windows, It’s understood there will have to be a Linux port of the library for the Linux build to work, but I’d like to keep the calling code as generic as possible.
You could write an intermediary interface to provide functions like
LoadLib(),LoadSym(), etc, that calls the aproppriate native API. In other words, when compiling for WindowsLoadLib()will useLoadLibraryA()and on Linux it will usedlopen().This will let you hide this ugly part of the code from your main code so it stays more readable.