LNK2005 Link errors when doing Release Build?? 
Author Message
 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



Thu, 23 Aug 2001 03:00:00 GMT  
 LNK2005 Link errors when doing Release Build??
Hello,

I've been able to get a clean compile and link in a ReleaseMinDependency
build.  The main problem seemed to have been that I had to delete a
"_ATL_MIN_CRT" switch in the settings.

This also compiles and links in a ReleaseMinSize build, but with this
build, I am continuing to get an LNK4006 warning:

================================================================
Linking...

in msvcrtd.lib(dllmain.obj); second definition ignored
   Creating library ReleaseMinSize/foo.lib and object
ReleaseMinSize/foo.exp
Registering ActiveX Control...

foo.dll - 0 error(s), 20 warning(s)
=================================================================

I've tested this build, and it seems to be working, but I am STILL a
little bothered about the above warning.  

Can anyone suggest what I might do to eliminated/avoid this warning in
the build???

Thanks in advance,
Jim

Quote:

> 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



Thu, 23 Aug 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. LNK2005 Link errors when doing Release Build??

2. PRB: LNK2005 Errors When Link C Run-Time Libraries Are Linked Before MFC Libraries (Q148652)

3. Link Errors : error LNK2005 and LNK2004

4. Error in Release build but not Debug build

5. VC6 Debug Build Works Fine - but Release Build Gives Error

6. Please Help! - Link Error LNK2005

7. help- Link error LNK2005

8. link problem, error LNK2005 using CSocket

9. Please Help! - Link Error LNK2005

10. Link error (LNK2005) - Any suggestions

11. DLL release build fails at link time

12. Debug build fine, release crashes unless we link with debug Multi-Threaded library

 

 
Powered by phpBB® Forum Software