
LNK2005 Link errors when doing Release Build??
Hello,
I have a VC++ 5 project (a DLL) that compiles and links fine in a Debug
build.
However, when I tried to compile for a Release build (any Release build,
i.e., ReleaseMinSize, ReleaseMinDependency, etc.), I am getting some
LNK2005 (xxx already defined in StdAfx.obj) errors, and depending on how
I set the 'Project Settings-General-Microsoft Foundation Class' and
'Project Settings-C++-Code Generation-User Runtime library' settings, it
sometimes seem to trying to pull in '_main', '_argv', etc.
The LNK2005 errors are saying the 'new' and 'delete' and '_fltused' are
already defined in StdAfx.obj, coming from msvcrt.lib, nafxcw.lib, or
libcmt.lib.
The best that I've been able to manage is 1 LNK2005 error ('Use MFC in a
Shared DLL' and 'Multithreaded DLL'):
=======================================================
Linking...
msvcrt.lib(dllsupp.obj) : error LNK2005: __fltused already defined in
StdAfx.obj
msvcrt.lib(dllsupp.obj) : warning LNK4006: __fltused already defined in
StdAfx.obj; second definition ignored
Creating library ReleaseMinDependency/foo.lib and object
ReleaseMinDependency/foo.exp
ReleaseMinDependency/foo.dll : fatal error LNK1169: one or more multiply
defined symbols found
Error executing link.exe.
foo.dll - 2 error(s), 5 warning(s)
=========================================================
Here's what I get when I set 'Use MFC as a Static Library' and
'Multithreaded':
==============================================================
Linking...
nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator
nafxcw.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator
definition ignored
nafxcw.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator
definition ignored
Creating library ReleaseMinDependency/foo.lib and object
ReleaseMinDependency/foo.exp
libcmt.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinDependency/foo.dll : fatal error LNK1120: 1 unresolved
externals
Error executing link.exe.
foo.dll - 4 error(s), 2 warning(s)
=============================================================
I've tried the 'ignore library' thing (adding the .lib to the 'ignore
library' and 'library' settings), but in most cases, that generated even
more link errors (mostly unresolveds).
Can anyone suggest what I might be doing wrong, or what I should do to
get this to link clean? BTW, I'd especially like to have to built
'Using MFC in a Static library'.
Thanks in advance,
Jim