[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2463
  • Last Modified:

Converting from MFC in Static Library to Shared DLL

I am using Visual C++ 5.0 and I am working on a project
which currently links to MFC as a Static Library.  I need
to convert this project so that it links to MFC as a Shared
DLL.  I changed the project setting to "Use MFC in a Shared
DLL."  However, now I get many link errors.  Here are
the some of the errors:

Linking...
LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _calloc already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(strftime.obj) : error LNK2005: _strftime already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in msvcrtd.lib(MSVCRTD.dll)
libcimtd.lib(ostream.obj) : error LNK2005: "public: class ostream & __thiscall ostream::operator<<(char const *)" (??6ostream@@QAEAAV0@PBD@Z) already defined in msvcirtd.lib(MSVCIRTD.dll)
nafxcwd.lib(afxmem.obj) : error LNK2005: "public: static void * __stdcall CObject::operator new(unsigned int)" (??2CObject@@SGPAXI@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxmem.obj) : error LNK2005: "public: static void __stdcall CObject::operator delete(void *)" (??3CObject@@SGXPAX@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,char const *,int)" (??2@YAPAXIPBDH@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxmem.obj) : error LNK2005: "public: static void * __stdcall CObject::operator new(unsigned int,char const *,int)" (??2CObject@@SGPAXIPBDH@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(objcore.obj) : error LNK2005: "public: int __thiscall CObject::IsKindOf(struct CRuntimeClass const *)const " (?IsKindOf@CObject@@QBEHPBUCRuntimeClass@@@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxinl1.obj) : error LNK2005: "public: virtual void __thiscall CObject::Serialize(class CArchive &)" (?Serialize@CObject@@UAEXAAVCArchive@@@Z) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxinl1.obj) : error LNK2005: "public: int __thiscall CString::GetLength(void)const " (?GetLength@CString@@QBEHXZ) already defined in mfc42d.lib(MFC42D.DLL)
nafxcwd.lib(afxinl1.obj) : error LNK2005: "public: __thiscall CString::operator char const *(void)const " (??BCString@@QBEPBDXZ) already defined in mfc42d.lib(MFC42D.DLL)

What is the problem?
0
kaplan1
Asked:
kaplan1
  • 2
1 Solution
 
jhanceCommented:
In the Project Settings/Link menu remove any Object/library module specifications that you have included.
0
 
kaplan1Author Commented:
I removed the one library (Winmm.lib) listed in the Project Settings/Link menu's
Object/library module specifications, and it did not make any difference.
0
 
trestanCommented:
You have to remove the libs you used one by one to see which one cause the problem. The error is occurred because one function may be defined in more than one libs. Also please take a look at the article:
http://support.microsoft.com/support/kb/articles/q148/6/52.asp
0
 
trestanCommented:
In your project setting's input catagory:
Add LIBCMTD.lib msvcrtd.lib to both object/library modules and the next ignore libraries edit boxes and recompile your project to see what happened. Good luck.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now