본문 바로가기

MS/MFC

r6034 attempt to load the C runtime library incorrectly

컴파일 다하고 debug 모드에서 실행시킬려고 하니까 아래 R6034 에러(아래그림)가 떴다. (그림은 인터넷에서 가져온 것이지만 에러내용은 동일)




한참 구글링해도 manifest가 어쩌고 저쩌고 하는 내용이었고, 나는 이미 vs 2005에서 컴파일한 터라 더 이상 어떻게 할 게 없었다. 막막한 마음에 혹시나 해서, 컴파일시 warning을 보니
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib "msvcrt.lib"
conflicts with use of other libs; use /NODEFAULTLIB:library

라는 warning 이 맨 마지막 줄에 있었다.... 사실 이 warning은 자주 나타나는 거라서 그냥
warning 수준에서 무시 했었는데, 암튼 혹시나 해서 구글링해서
http://www.stanford.edu/~yljiang/pages/GPRS%20Linking%20Warning.htm
에서 아래와 같은 방법을 찾아서 했더니, 에러가 사라졌다....
해서 황당해서 여기에 기록해 둔다.

Linker Tools Warning LNK4098

defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB:library
You are trying to link with incompatible libraries.
Important The run-time libraries now contain directives to prevent mixing different types. You’ll receive this warning if you try to use different types or debug and non-debug versions of the run-time library in the same program. For example, if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, you’ll get this warning. You should compile all source files to use the same run-time library. See the Use Run-Time Library (MD, /ML, /MT, /LD) compiler options for more information.
You can use the linker’s /VERBOSE:LIB switch to determine which libraries the linker is searching. If you receive LNK4098 and want to create an executable file that uses, for example, the single-threaded, non-debug run-time libraries, use the /VERBOSE:LIB option to find out which libraries the linker is searching. The linker should print LIBC.LIB and not LIBCMT.LIB, MSVCRT.LIB, LIBCD.LIB, LIBCMTD.LIB, or MSVCRTD.LIB as the libraries searched. You can tell the linker to ignore the the incorrect run-time libraries by typing the incorrect libraries in the Ignore Libraries text box on the Link tab of the Settings dialog box in Developer’s Studio or by using the /NODEFAULTLIB:library option with LINK for each library you want to ignore. See the Ignore Libraries (/NODEFAULTLIB) linker option for more information.
The table below shows which libraries should be ignored depending on which run-time library you want to use.
To use this run-time library
Ignore these libraries
Single-threaded (libc.lib)
libcmt.libmsvcrt.liblibcd.liblibcmtd.libmsvcrtd.lib
Multithreaded (libcmt.lib)
libc.libmsvcrt.liblibcd.liblibcmtd.libmsvcrtd.lib
Multithreaded using DLL (msvcrt.lib)
libc.liblibcmt.liblibcd.liblibcmtd.libmsvcrtd.lib
Debug Single-threaded (libcd.lib)
libc.liblibcmt.libmsvcrt.liblibcmtd.libmsvcrtd.lib
Debug Multithreaded (libcmtd.lib)
libc.liblibcmt.libmsvcrt.liblibcd.libmsvcrtd.lib
Debug Multithreaded using DLL (msvcrtd.lib)
libc.liblibcmt.libmsvcrt.liblibcd.liblibcmtd.lib
For example, if you received this warning and you want to create an executable file that uses the non-debug, single-threaded version of the run-time libraries, you could use the following options with the linker:
/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib

그리고, 아래는 문제를 해결하고 난 이후에 찾은 글이다.

http://weblogs.asp.net/george_v_reilly/archive/2007/02/10/shell-extension-throwing-r6034-errors.aspx

Shell extension throwing R6034 errors

I have been cleaning up some issues with the Win64 port of Vim, including the Edit with Vim shell extension not working very well. When I built the shell extension with VS 2005 on x86, I would get the following whenever I right-clicked in Explorer:
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: C:\WINDOWS\Explorer.EXE
R6034
An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.
There was no mention of which application was at fault, though it was obvious in this case. I have also seen some mention of verclsid in the error dialog, though not when I took this snapshot.
The underlying problem relates to SxS, Fusion, and all that good stuff. By far the simplest fix was for me to statically link with libcmt.lib, instead of msvcrt.lib, rather than figure out the necessary manifest magic.





At the time of 2009 Jun 20, I got this error again and found a solution from the following (Scrapped from : http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/6d16ecce-f92b-4c53-a45b-40119c4566a6)

Hi there,

I read every post in this thread without any help in my case.

The problem turned out: The DEBUG version was trying to link with BOTH msvcr80.dll and msvcr80d.dll.

Check if this is the case for you using the "dependency walker" on your executable. If these two are both loaded, then you got the same problem as I did.

The solution is to set "Properties->Linker->Input->Ignore Specific library" to "msvcrt.lib".

 

More details below:

I was compiling and running a program that uses opencv library. Oneof the libraries in opencv (highgui to be exact) was linking withnon-debug versions of some graphics libraries even in its debugversion. Apparently this was OK before. 

This resulted in my debug version program linking with bothmsvcr80.dll and msvcr80d.dll. It appears this is a problem since themanifest only mentions one of these libraries and the other one(msvcr80.dll) appears not to be found causing the error mentioned inthis thread. Why no-one in this thread mentioned that this could be thecase is beyond me. I found out about this using "dependency walker" onthe .exe that I compile and/or the highgui100d.dll that I load from thelibrary.

That is the reason the complaint is about msvcr80.dll and not msvcr80d.dll in VS8!!!

The fix is to re-compile highgui100d.dll (debug version) withProperties->Linker->Input->Ignore Specific library set tosingly "msvcrt.dll".

Just wanted to add this so other people do not waste time as I did...

Hakan



출처 : http://cvision.egloos.com/6578706