I have an API which is implemented as a Regular DLL. The API uses MFC.
I have used the API from within MFC exe's for years without any problems.
I now want to use the API from within another DLL that is called from the main EXE.
I am trying to implement a plugin mechanism where the plugin is passed a MFC C Class that is created by the EXE (but which resides in a statically linked Regular DLL which uses dynamically loaded MFC).
So here is the flow:
(1) Exe starts and starts statically linked Regular DLL. Main interface is a class.
(2) Program then dynamically loads a 2nd DLL and passes a pointer to the API class.
When I statically link the 2nd DLL the program works fine until I shut down the exe and then I get heap corruption.
When I load the DLL with AfxLoadLibrary the DLL loads no problem but then gets access violations when it tries to access the 1st DLL.
I then tried implementing the 2nd DLL as an extension DLL and now I am getting:
mfcs100.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in dllmain.obj
This is doing my head in!
Any help greatly appreciated.