views:

35

answers:

1

When linking my dll in release build I get -

1>LINK : warning LNK4098: defaultlib 'mfc80d.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

1>LINK : warning LNK4098: defaultlib 'mfcs80d.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

1>LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

adding /VERBOSE, I see the following (snippet): ...

1> Searching D:\Microsoft Visual Studio 8\VC\atlmfc\lib\mfc80d.lib:

1> Found "public: virtual __thiscall AFX_MODULE_STATE::~AFX_MODULE_STATE(void)" (??1AFX_MODULE_STATE@@UAE@XZ) 1>
Referenced in mfcs80.lib(dllmodul.obj) 1> Loaded mfc80d.lib(MFC80D.DLL)

1> Found "long stdcall AfxWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?AfxWndProc@@YGJPAUHWND__@@IIJ@Z)

1> Referenced in mfcs80.lib(dllmodul.obj) 1> Loaded mfc80d.lib(MFC80D.DLL)

...

If I'm interpreting this correctly, it means the linker somehow resolves calls from the (optimized) library mfcs80, as calls into the (non-optimized) library mfc80D. How can this be??

When I add /NODEFAULTLIB:mfc80d.lib the warnings are gone, but I'm not quiet with it yet. As an aside, the module does indeed suffer from sporadic inexplicable crashes on incremental links, that are solved only by a re-build. I'm using VS2005.

[Edit:] Changed the title to include DEFAULTLIB, hopefully better focusing the subject. I do see an explicit line saying

processed /DEFAULTLIB:mfc80d.lib

in the /VERBOSE output, among many other (non-debug) default libs. Where does it come from? how can I fix this?

Thanks!

A: 

You should check the run-time library settings for your projects, sounds like you have a mismatch. In your project settings under C/C++ > Code Generation > Runtime Library, you have the choices:

  • Multi-Threaded
  • Multi-Threaded Debug
  • Multi-Threaded DLL
  • Multi-Threaded Debug DLL

It sounds like some of the projects in your solution may be using a Debug version while others use the Non-Debug version. Or alternatively, some projects may be using the Debug version while others are using the Debug DLL version. For a given solution configuration, you want all of the projects to use the same setting.

bshields
Thanks - but I checked all projects (and all individual files), and they're all compiled with /MD. I have very few external dependencies: version.dll, shlwapi.dll and a 3rd party component that i inspected with dependency-walker and seems to link with the proper CRT versions (non-debug). Is the /MD switch indeed the only access to the /DEFAULTLIB switch? Isn't there another input that might have messed it up?
Ofek Shilon