Wednesday, September 7, 2011

Handling - Runtime Error R6034 Application attempted to load the C runtime lib incorrectly

Handling - Runtime Error R6034, An application has made an attempt to load the C runtime lib incorrectly

  1. This could mean that you have linked against both the debug and release versions of the C runtime library (msvcrt.lib)
  2. This blog post is very useful: http://www.insidercoding.com/post/2008/07/21/Debugging-issues-with-MSVCR90DLL.aspx


Another possible cause is linking a debug version of a static library when building a release version of your executable. The executable will run on a development machine because the development machine has both the debug and release versions of the DLL installed (



Adding MSVCPRTD.LIB to the list of ignore libraries prevented that library being automatically linked to the project. This caused the linker to show which static library was trying to import the debug dll.

NOTE: Need to create a test project.... an exe which imports a static lib. That static lib should be built in debug config and should use a debug function....... when the exe is built in release mode it will not run on a customer machine (one that doesn't have VS installed) and will bomb out.... show error message there.... But how can you figure out what DLL it is trying to load (maybe it's in the error message).... a good way is to use depends.exe..... check out the profiling tool in it..... show clearly that both the debug and release versions of depends are being searched for... Depends also shows what function that exe is trying to call in the debug version of the DLL..... But how can you figure out which static library that you're linking against is causing this?

So now you know the DLL and the function in the dll you can continue debugging.... the next step is to add the MSVCPRTD.LIB to the ignore specific libraries since you know you don't want to include this..... explain what the MSVCPRTD.LIB is.... also discuss other potential libraries which could cause this error.... finally try building the exe with this setting.... if the correct library is ignored then the static library will not link correctly and the link will fail.... the linker error message will display the function as a missing external symbol and also show which static library the function is being called from.... in my case the static lib I was linking against was built in debug mode but accidentally copied into the Release folder.... I simply dropped in my release version of the static lib, rebuilt and everything worked....


MSVCPRTD.LIB; msvcrtd.lib

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete