Solved

Converting from MFC in Static Library to Shared DLL

Posted on 1998-08-18
4
2,382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
Expand data scrubbing tool 13 36
mapBully challenge 6 177
Is there a simple front-end menu system. 9 118
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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

762 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