PRB: L2025 with a CWinApp-Derived Class in an Extension DLLLast reviewed: July 18, 1997Article ID: Q117564 |
7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbprg kbprb
The information in this article applies to:
SYMPTOMSIt can be useful to define and export (not necessarily instantiate) a CWinApp-derived class within an MFC-extension DLL (_AFXDLL defined). However, the linker generates the following:
d:\msvc\mfc\lib\mfc250d.lib(dumpout.cpp) : error L2025: _AfxTrace : symbol defined more than once d:\msvc\mfc\lib\mfc250d.lib(afxmem.cpp) : error L2025: void __far* __far __cdecl operator new(unsigned int) : symbol defined more than once d:\msvc\mfc\lib\mfc250d.lib(afxmem.cpp) : error L2025: void __far* __far __cdecl operator new(unsigned int,char const __far*,int) : symbol defined more than once d:\msvc\mfc\lib\mfc250d.lib(afxmem.cpp) : error L2025: void __far __cdecl operator delete(void __far*) : symbol defined more than once d:\msvc\mfc\lib\mfc250d.lib(afxmem.cpp) : error L2025: public: static void __far* __far __cdecl CObject::operator new(unsigned int) : symbol defined more than once d:\msvc\mfc\lib\mfc250d.lib(afxmem.cpp) : error L2025: public: static void __far* __far __cdecl CObject::operator new(unsigned int,char const __far*,int) : symbol defined more than once d:\msvc\mfc\lib\mfc250d.lib(afxmem.cpp) : error L2025: public: static void __far __cdecl CObject::operator delete(void __far*) : symbol defined more than once d:\msvc\lib\ldllcew.lib(fmalloc.asm) : error L2025: __fmalloc : symbol defined more than once d:\msvc\lib\ldllcew.lib(fmalloc.asm) : error L2025: __ffree : symbol defined more than once CAUSEThe CWinApp::_ForceLinkage member function of the CWinApp class forces the routines mentioned in the error messages to be linked in from the file DLLINIT.CPP. This member function is used only by the MFC libraries. Having these routines defined in DLLINIT.CPP as well as in the class libraries causes the error message "symbol defined more than once". The _fmalloc, _free, new, and delete errors can also be caused by a call to AfxCheckMemory() in a MFC extention DLL. This problem can occur with or without a CWinApp derived class.
RESOLUTIONTo work around the problem, override CWinApp::_ForceLinkage(). The function should do nothing, but it prevents the base class function from linking in the DLLINIT.CPP file. This is not a problem with Visual C++ 32-bit Edition, because there is no CWinApp::_ForceLinkage. Calling AfxCheckMemory() is also safe from a 32-bit extension DLL.
MORE INFORMATIONThe following sample code is an example of a CWinApp-derived class that might be included in an _AFXDLL DLL with a _ForceLinkage() member declaration:
Sample Code
/* Compile options needed: /D_AFXDLL */ class CMyApp: public CWinApp { ... void _ForceLinkage() { #ifndef _WINDLL CWinApp::_ForceLinkage(); #endif } ... }; |
Additional reference words: 7.00 1.00 1.50 2.00 2.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |