5
votes

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!

3

3 Answers

2
votes

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.

2
votes

The issue was resolved much later - I post it up here in case it helps somebody someday.

It turned out to be a wrong precompiled header path: release configuration pointed to the default debug PCH path. So on transition from debug to release, a build would drag in all the debug PCH contents - apparently including some debug versions of MFC #pragma (comment "lib..") (included in afx headers). A clean build would rebuild the PCH correctly, but again into the debug folder - thereby causing identical problems on transition back to debug build.

0
votes

It means that one of the dependent dlls is compiled with a different run-time library.

Project -> Properties -> C/C++ -> Code Generaion -> Runtime Library

Go over all the libraries and see that they are compiled in the same way.

More about this error in this link:

warning LNK4098: defaultlib "LIBCD" conflicts with use of other libs