Adding MFC to a non-MFC project
-
As an example, there is a project posted here on codeproject (by John Roark) that displays a "skinned" dialog (sorry I don't have the link at this time). If I try to add a CStatic derived class to it, I keep getting link errors (see below). I am using the "Use MFC in a static library" option. Using a shared dll option does not produce the error, but I need to have the static library option. Every search I do keeps telling me that I can solve this error by selecting one of the Multi-Threaded options in the "Code Generation" tab of VC6. The thing is - I already have the Multi-Threaded option picked.:mad: I'm really hoping that this is a very simple problem to solve, but I'm stumped. Any ideas? Thanks, David Link errors: nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) Debug/SkinTrial.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe.
-
As an example, there is a project posted here on codeproject (by John Roark) that displays a "skinned" dialog (sorry I don't have the link at this time). If I try to add a CStatic derived class to it, I keep getting link errors (see below). I am using the "Use MFC in a static library" option. Using a shared dll option does not produce the error, but I need to have the static library option. Every search I do keeps telling me that I can solve this error by selecting one of the Multi-Threaded options in the "Code Generation" tab of VC6. The thing is - I already have the Multi-Threaded option picked.:mad: I'm really hoping that this is a very simple problem to solve, but I'm stumped. Any ideas? Thanks, David Link errors: nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) Debug/SkinTrial.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe.
Are you linking to any other static libraries? They will also need the same settings. One other thing - sometimes it is easer not to fight these types of errors and create a clean project from scratch. In other words, create a new project (DSP), making sure to select that you are using MFC statically. Then add your files, making sure things still compile. Chances are this will work, or at least help you narrow down the culprit. Even a broken clock is right twice a day.
-
As an example, there is a project posted here on codeproject (by John Roark) that displays a "skinned" dialog (sorry I don't have the link at this time). If I try to add a CStatic derived class to it, I keep getting link errors (see below). I am using the "Use MFC in a static library" option. Using a shared dll option does not produce the error, but I need to have the static library option. Every search I do keeps telling me that I can solve this error by selecting one of the Multi-Threaded options in the "Code Generation" tab of VC6. The thing is - I already have the Multi-Threaded option picked.:mad: I'm really hoping that this is a very simple problem to solve, but I'm stumped. Any ideas? Thanks, David Link errors: nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) Debug/SkinTrial.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe.
You probably need to do some more. There is an article in MSDN that describes what you have to do to add MFC support to an ATL project. It is pretty generalizable advice. Search for "Howto MFC ATL" to find the article.