PRB: L2029 Error on AFX_EXCEPTION_LINK When Building MFC DLL

Last reviewed: July 18, 1997
Article ID: Q132341
1.00 1.50 1.51 1.52 WINDOWS kbprg kbprb

The information in this article applies to:

  • Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52

SYMPTOMS

When building a DLL that uses the Microsoft Foundation Classes (MFC), the Visual C++ linker reports the following error:

   error L2029: 'public: __far __pascal
   AFX_EXCEPTION_LINK::AFX_EXCEPTION_LINK(void)__near' :
   unresolved external

CAUSE

The MFC User DLL (_USRDLL) or Extension DLL (_AFXDLL) that you are building is made up of static libraries (.LIB) that also contain MFC code, and there is a TRY/CATCH/END_CATCH block in the static library code.

The problem occurs because of the compiler options used to build the static library. AFX_EXCEPTION_LINK needs to be defined as a __far struct rather than as a __near struct.

RESOLUTION

You need to make sure the static libraries are compiled with the same options you use to build the _USRDLL or _AFXDLL because that is where the code is being used. For example, you need to define the preprocessor symbol "_USRDLL" for _USRDLLs, and "_AFXDLL" for _AFXDLLs. You also need to compile for large memory model for both types of DLLs.

STATUS

This behavior is by design.

MORE INFORMATION

For more information on building _USRDLLs, please see MFC Tech Note 11. For more information on building _AFXDLLs, please see MFC Tech Note 33.


Additional reference words: 1.00 1.50 5.5 5.6 5.50 5.60 5.60.339
KBCategory: kbprg kbprb
KBSubcategory: MfcDLL
Keywords : kb16bitonly MfcDLL kbprb kbprg
Technology : kbMfc
Version : 1.00 1.50 1.51 1.52
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.