LNK4098: defaultlib "mfc42d.lib" conflicts in Release build - visual-c++

After several hours of stretching my hairs, I can't figure this out. In Debug version, it is working fine. But in release mode, I am getting this warnings and eventually an runtime error. As far as I know, these libraries are debug versions. Why is my release build looking for these libraries and how can I stop it? FYI, I looked at settings and project files to find a clue in vain.
LINK : warning LNK4098: defaultlib "mfc42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcs42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library

Impossible to tell without more information why your project is including these. My guess is that you are linking with a debug configuration of some other library, which is pulling in those dependencies. If you increase the verbosity of the linker settings then it may show you which files are including them.
The fix though is given in the error message. Add /nodefaultlib:mfc42d.lib/nodefaultlib:mfcs42d.lib /nodefaultlib:msvcrtd.lib to the linker arguments.

Related

Duplicate Symbols in Phonegap Urbanairship Plugin for iOS

I am in the middle of integrating UA into my Phonegap/iOS application using the UA Phonegap plugin https://github.com/urbanairship/phonegap-ua-push.
Unfortunately, I can not get it to work. Even the sample project fails to build. The problem is a duplicate symbol during linking. Please note: i did not include any additional headers, libs, etc. I am just trying to build the iOS sample project.
The clashing symbol seems to be rooted in the ASI* (ASIHttpRequest, ASIAuthenticationDialog, etc) library, which has been integrated into UA. Surprisingly, the clashing happens between both UA libs (libUAirship-1.3.2.a and libUAirshipPush-1.3.2.a).
Linker output: ld: duplicate symbol _OBJC_METACLASS_$_UA_ASIAutorotatingViewController in /Users/b/Downloads/urbanairship-phonegap-ua-push-9b7a89b/ios-sample/Airship/libUAirshipPush-1.3.2.a(UA_ASIAuthenticationDialog.o) and /Users/b/Downloads/urbanairship-phonegap-ua-push-9b7a89b/ios-sample/Airship/libUAirship-1.3.2.a(UA_ASIAuthenticationDialog.o) for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can this happen?
This issue appeared for me when I add the flag "-ObjC" in my target settings at "Other Linker Flags".
Check it, i need the flag for an another library but if it's not your case...

is it possible to link a c++/cli dll with a static vc++ lib

I got the c++/cli dll to link to a vc++ dll, but when trying it with the static version of the vc++ lib there are a bunch of linker errors. I want to use static so I dont have to copy all of the other vc++ dll files into my main c# project, which uses the c++/cli dll.
The vc++ library has the following properties:
*built in vs2008
*Static library
*uses MFC in a static library
*No common language runtime support
the c++/cli library has these properties:
*built in vs2010
*Dynamic Library
*Use of MFC in a shared DLL
*Common Language Runtime Support
*linker->input contains the vc++ lib file
I tried linking the vc++ lib it after building it in vs2010 but that didn't help.
So I get like 90 LNK2005 errors like these from nafxcwd.lib:
1>nafxcwd.lib(dlgprop.obj) : error LNK2005: "public: struct _PROPSHEETPAGEA & __thiscall CPropertyPage::GetPSP(void)" (?GetPSP#CPropertyPage##QAEAAU_PROPSHEETPAGEA##XZ) already defined in mfc100d.lib(mfc100d.dll)
then like 30 or so of these:
1>libcmtd.lib(sprintf.obj) : error LNK2005: _sprintf already defined in msvcrtd.lib(MSVCR100D.dll)
then three LNK4098 warnings:
LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'nafxcwd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'libcmtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
then I get this last error:
libcmtd.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup
I looked up the LNK4098 warning on msdn and the solution was to add the conflicting libraries to the IgnoreSpecific Default libraries entry in the linker input settings, but this did not help.
Thanks,
alex
You can't link (C++) libraries build with different version of the VS compiler (sometimes it may accidentally seem to work but you'll usually get hard to diagnose crashes later on). Additionally, your errors seem to be typical of selecting different CRT configurations (single/multi-threaded, debug/release etc).

LNK4099 in GLFW console project with debug configuration

When compiling a win32 console project with GLFW in Visual Studio 2010 SP1, I am getting the following warning for debug configuration:
Warnung 1 warning LNK4099: PDB "vc100.pdb" wurde nicht mit "GLFW.lib(enable.obj)" oder an "C:\path-to-project with-spaces\World\Debug\vc100.pdb" gefunden; Objekt wird verknüpft, als ob keine Debuginformationen vorhanden wären. C:\path-to-project with-spaces\World\World\GLFW.lib(enable.obj) World
13 more for GLFW.lib(enable.obj), GLFW.lib(glext.obj), GLFW.lib(image.obj), GLFW.lib(init.obj), GLFW.lib(input.obj), GLFW.lib(stream.obj), GLFW.lib(tga.obj), GLFW.lib(win32_enable.obj), GLFW.lib(win32_fullscreen.obj), GLFW.lib(win32_glext.obj), GLFW.lib(win32_init.obj), GLFW.lib(win32_time.obj), GLFW.lib(win32_window.obj), GLFW.lib(window.obj)
And last but not least:
Fehler 15 error LNK1104: Datei "C:\path-to-project with-spaces\World\Debug\World.exe" kann nicht geöffnet werden. C:\path-to-project with-spaces\World\World\LINK World
The release configuration is compiling. This is probably still not enough information for solving my problem, but I would appreciate an explanation for why this can happen.
I don't know what the warnings/errors are saying because I don't know any German whatsoever, but generally if something compiles/links for release but not debug (or vice-versa) this means you're linking to the wrong libraries for the one that isn't working. Are there specific debug libraries (.dll's or .lib's) for the GLFW library? Sometimes you have to tell VS to use one for your project's release configuration and a different one for your project's debug configuration. Check for something like glfw.lib and glfw_d.lib, where the _d would indicate the debug library.
Or if you could supply the English translation of the link warnings/errors I might be able to help more.
Good luck!
Whenever building a project with VC++ fails, it's best to consult the MSDN with the error code. In your case http://msdn.microsoft.com/en-en/library/b7whw3f3(v=vs.80).aspx
Linker Tools Warning LNK4099 PDB 'filename' was not found with
'object/library' or at 'path'; linking object as if no debug info The
linker was unable to find your .pdb file. Copy it into the directory
that contains object/library.
To find the name of the .pdb file associated with the object file:
Extract an object file from the library with lib
/extract:objectname.obj xyz.lib.
Check the path to the .pdb file with dumpbin /section:.debug$T
/rawdata objectname.obj.
You could also compile with /Z7, so the pdb doesn't need to be used,
or remove the /DEBUG linker option if you do not have .pdb files for
the objects you are linking.
I was already using the right lib for debug configuration but was not only linking to GLFW.lib but also to GLFWDLL.lib. You can either compile GLFW into you executeable by using GLFW.lib or use a DLL by linking to GLFWDLL.lib. I accidentally did both.
Additional info at
4.2 Link with the right libraries
in the current GLFW 2.7 Release Notes.

Trying to install Image.Codec.DevIL under windows. Needs pthread and IL. Can't get IL to work

This is the output from cabal install codec-image-devil:
Resolving dependencies...
Configuring Codec-Image-DevIL-0.2.3...
cabal: Missing dependency on a foreign library:
* Missing C library: IL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal: Error: some packages failed to install:
Codec-Image-DevIL-0.2.3 failed during the configure step. The exception was:
ExitFailure 1
I tried --extra-include-dirs and --extra-lib-dirs. but they didn't work. so I edited the .cabal in Codec-Image-DevIL-0.2.3.tar.gz. I don't know if I'm even supposed to change that. but it worked for pthread.
I added these two lines:
include-dirs: C:\Users\Rumbold\Documents\libs\IL\include, C:\Users\Rumbold\Documents\libs\pthread\include, .
extra-lib-dirs: C:\Users\Rumbold\Documents\libs\IL\lib, C:\Users\Rumbold\Documents\libs\pthread\lib, .
They are indented so they are in the Library section. I don't know if I got the format for lists right, just something i stumbled upon while googling. The libs and `header files are all in the correct place, I think.
any clue how i can get it to work?
Edit_1:
I got it to work with --extra-include-dirs and --extra-lib-dirs, so I don't need to edit the cabal anymore. but IL still doesn't work. is there a way to find out which files it's looking for?
Wdit_2:
Alright it works. I had to rename DevIL.lib and DevIL.dll to libIL.lib and libIL.dll. (not sure if I had to do both, but that's what I did. also kept them under their old names)
Edit_3:
Getting lots of errors like:
"cabal\Codec-Image-DevIL-0.2.3\ghc-6.12.3/libHSCodec-Image-DevIL-0.2.3.a(DevIL.o):fake:(.text+0x2379):
undefined reference to `ilGetInteger#4'"

VC++ /DEFAULTLIB issue

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!
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.
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.
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

Resources