Solved

Converting from MFC in Static Library to Shared DLL

Posted on 1998-08-18
4
2,323 Views
Last Modified: 2013-11-20
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
Comment
Question by:kaplan1
  • 2
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1320966
In the Project Settings/Link menu remove any Object/library module specifications that you have included.
0
 

Author Comment

by:kaplan1
ID: 1320967
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
 
LVL 8

Accepted Solution

by:
trestan earned 200 total points
ID: 1320968
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
 
LVL 8

Expert Comment

by:trestan
ID: 1320969
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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now