PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

MFC sample(vs2005-pc) cannot be built,please help me out!

The latest release GapiDraw3.6, it's MFC sample(vs2005-pc) cannot be built in Debug version.

The following are the error messages:
atlsd.lib(atltypes.obj) : error LNK2005: "public: __thiscall CPoint::CPoint(void)" (??0CPoint@@QAE@XZ) already defined in gapidraw.lib(GapiSurface.obj)
atlsd.lib(atltypes.obj) : error LNK2005: "public: __thiscall CRect::CRect(void)" (??0CRect@@QAE@XZ) already defined in gapidraw.lib(GapiDisplayCommon.obj)
atlsd.lib(atltypes.obj) : error LNK2005: "public: __thiscall CRect::CRect(struct tagRECT const &)" (??0CRect@@QAE@ABUtagRECT@@@Z) already defined in gapidraw.lib(GapiSurface.obj)
atlsd.lib(atltypes.obj) : error LNK2005: "public: __thiscall CRect::operator struct tagRECT *(void)" (??BCRect@@QAEPAUtagRECT@@XZ) already defined in gapidraw.lib(GapiSurface.obj)
atlsd.lib(atltypes.obj) : error LNK2005: "public: int __thiscall CRect::PtInRect(struct tagPOINT)const " (?PtInRect@CRect@@QBEHUtagPOINT@@@Z) already defined in gapidraw.lib(GapiSurface.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
Attachments:
MFC.rar (104 KB)
InexorableTash · 15 Sep 2006, 03:40 UTC
Try going to the project settings, linker, and setting the "Ignore default libraries:" to include msvcrt.lib

(I'm away from home right now so can't repro the problem. I'll try next week if no-one solves this first.)
InexorableTash · 19 Sep 2006, 03:24 UTC
Ah, ignore my previous comment. I wasn't seeing the real problem.

Both MFC (as of VS2005, now using ATL) and GapiDraw define CPoint and CRect types in the global namespace.

The real fix would be for one of those libraries to stuff the types into a namespace, but that's out of your control. A safe (but time consuming) fix would be to wrap one of the libraries in another library that exposes namespaced types.

An actually practical workaround is to specify "/FORCE:MULTIPLE" in the Project Settings : Linker : Command Line : Additional Options field. This tells the linker to go ahead and link ignoring the error. This is safe in this example because both the GapiDraw and the ATL types for CPoint and CRect extend the Win32 tagPOINT and tagRECT types, and don't define any storage. So as long as the methods with the same names do the same things, it works.
InexorableTash wrote:Both MFC (as of VS2005, now using ATL) and GapiDraw define CPoint and CRect types in the global namespace.


Yes, that's the primary reason why we did not bother in making the MFC sample compile in DEBUG mode. Too much changes involved.

The MFC sample still works in release mode in VS2005, and in all modes (DEBUG and RELEASE) in all other environments than VS2005.

Cheers
Johan