Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi
I have a project from the MFC/C++ VS2010, but I need to use ".NET Library" inside of my project. Actually I need to have a native and manged code at same time. So I am trying to use CLI/C++ facilities and integration, for that purpose I created "Empty CLI" project from the VS2010 and then I added all of my MFC source inside of this project, But When I want to the build it, I get these errors:

Error 4 error LNK2005: "public: virtual int __thiscall CComboEdit::PreTranslateMessage(struct tagMSG *)" (?PreTranslateMessage@CComboEdit@@UAEHPAUtagMSG@@@Z) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem

Error 16 error LNK2005: "protected: void __thiscall CInPlaceList::OnKeyUp(unsigned int,unsigned int,unsigned int)" (?OnKeyUp@CInPlaceList@@IAEXIII@Z) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem

Error 15 error LNK2005: "protected: void __thiscall CInPlaceList::OnKeyDown(unsigned int,unsigned int,unsigned int)" (?OnKeyDown@CInPlaceList@@IAEXIII@Z) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem

Error 12 error LNK2005: "protected: virtual struct AFX_MSGMAP const * __thiscall CInPlaceList::GetMessageMap(void)const " (?GetMessageMap@CInPlaceList@@MBEPBUAFX_MSGMAP@@XZ) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem

Error 17 error LNK1561: entry point must be defined D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\LINK EngSystem


Additionally from the GridCellCombo.cpp I have these library
C++
#include "../stdAfx.h"
#include "../UserView.h"
#include "../GridCtrl_src/GridCell.h"
#include "../GridCtrl_src/GridCtrl.h"

#include "GridCellCombo.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


any help would be appreciated.

Best Regards.
Homay
Posted
Updated 6-Apr-13 17:30pm
v3
Comments
Sergey Alexandrovich Kryukov 6-Apr-13 19:16pm    
Something can always be missing; it's hard to say without seeing your project. I would advise to do the opposite: start from MFC template and then add a CLI option to it. Better yet, migrate to .NET completely: for UI, MFC is nothing good compared to .NET System.Window.Forms of WPF.
—SA

1 solution

Somehow you are including some of your source twice. This can happen from a number of scenarios but here are my first guesses:
- You have one or more of the methods implemented in header files instead of the .cpp files (not a good way to do it). The header files are included at least twice somewhere (this part is not uncommon).
- You have a source file included twice in your project.
- Some bizarre things can sometimes happen if your base class is implemented in one dll and a derived class is in a different dll (more details required).
- ...

Also, if you have a mixed mode DLL, I believe with VS2010 it needs to be called from a /CLR executable (I have done this with VS2005, but Microsoft changes the rules from version to version and I am not 100% with what the rules are for VS2010). I think it is still correct with VS2010 that you need to first make your .exe mixed mode, then all DLLs in the chain from executable to the DLL you are describing above. No unmanaged DLLs can call managed code. Your mixed mode DLLs can call either managed or unmanaged code.

[If I have said something incorrect here, anybody please feel free to jump in and correct me...]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900