troubleshooting Question

Accessing Regular DLL from another DLL

Avatar of gazillabyte
gazillabyteFlag for United States of America asked on
Visual C++.NETDB Dev Tools
14 Comments1 Solution1807 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros