Using one extension DLL in another

If you create an extension DLL you can most conveniently export one or more of its classes using AFX_EXT_CLASS. However if you create a second extension DLL and try to use classes from the first you will run into a small problem.

The value of AFX_EXT_CLASS will cause your new DLL to try and export your dependent classes! You will get link errors such as below for the classes in the first DLL:

error LNK2001: unresolved external symbol ..........

What you need to do is temporarily re-define AFX_EXT_CLASS when you include the header files for the classes in the DLL you are importing classes from. The following example shows how to do this:

//change the definition of AFX_EXT... to make it import
#undef AFX_EXT_API

//Include headers for the dll / lib that we use classes from
#include "DLLOne.H"

//put the values back to make AFX_EXT_CLASS export again
#undef AFX_EXT_API

//Include headers for the classes we are creating in this DLL
#include "DLLTwo.H"

Posted: March, 8, 98


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Featuring Mary Wardley, VP, Enterprise Applications and CRM Software, IDC Live Event Date: Wednesday, November 16, 2016 10 AM PT / 1 PM ET Significant changes are coming to the contact center, with new technologies enabling better customer engagement, innovative journey analytics and streamlined proactive communications. But the future holds some amazing advances which will change the role of the contact center in tomorrow's organizations. This is a critical time to understand what's coming and how an agile …

  • Today's enterprise datacenter can be one of the most complex business environments with dozens (for smaller business), hundreds (for larger and midsize business), even thousands (for hyperscale businesses) of servers that must be managed and monitored. At this level, just managing the cords can be challenging — let alone keeping up with the growing need for more agility and scalability within the datacenter. Simply put, companies are aggressively looking for less complexity and more agility from their …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date