Visual C++ application fails with the runtime error R6034 "An application has made an attempt to load the C runtime library incorrectly."
There can be many reasons for the crash. We should check some of the obvious reasons for it.
I have listed some of them here:1. Check to see if the manifest has multiple runtimes. See the following blog article for steps to check this:
Troubleshooting Manifest-Related Issues
2. Check if the C runtime with which the application is built is lower/equivalent to the C runtime currently installed on the machine.The below blog articles will help you,
Part 1: Troubleshooting VC++ Side by Side ProblemsPart 2: Troubleshooting VC++ Side by Side Problems
3. The application should have either the Debug C runtime or Release C runtime. If it has a combination of both of them, you might end up getting the above runtime error. Developers should be aware of the runtime modules their application is dependent on.
In case if you are not, how do you check if both the runtimes are loaded? :
a. Set a break point in your application and check the modules loaded once the break point is hit. Press Ctrl + Alt + U. For VC++ 2008, check if both msvcr90 and msvcr90d,or both mfc90 and mfc90d.dll are loaded. For VC++ 2010, they will have “100” in the names instead. VC++ 2012 uses “110”, etc.If you are able to identify which module is loading the runtime (release or debug ) not required, build that module with the required runtime. You should be able to get past the error.b. However, if you are still not able to identify the module, follow the below steps that might be helpful. It might be because of the libraries statically linked with your exe. It is not mandatory for the developer who is diagnosing his own app to gather a link repro. The link repro is mainly for such developers to create something that you can share with your team or anyone who is helping you diagnose the issue. The original developer can simply use dumpbin (or “Link /dump”) to examine the directives of any .lib or .obj files you suspect. However, creating a link repro can be convenient for getting all of the input components into a single folder to assist in searching.
Link repro gets all the lib file and obj files into a folder . Link Repro is also handy to diagnose linker errors.Get a link repro
1) Create a folder C:\linkrepro
2) Go to Project ->Properties->Configuration Properties->Linker->CommandLine /linkrepro:c:\linkrepro
Build your application or the module.
3)Now open your Visual Studio Command prompt , go to the folder where you have set the link repro, in this case it is C:\linkrepro.
4)Run the cmd, “link /dump /directives *.lib *.obj > direct.txt”5) In the direct.txt search for the runtime, you think should not be loaded in my case it was msvcrt.dll .
Please note that Import name for msvcr90 lib is msvcrt, hence in the file you will see in direct.txt is msvcrt. For msvcr90d, it would be msvcrtd.lib instead.These were the results . Dump of file uknowme.2.lib
File Type: LIBRARY
Dump of file iknowu.2.lib
-defaultlib:OLDNAMESDump of file metl.2.lib
Dump of file blu.2.lib
-defaultlib:OLDNAMESDump of file rdd.2.lib
Further under msvcrt.lib confirming what we had said before , the import name for msvcr90.
Dump of file MSVCRT.lib
File Type: LIBRARYLinker Directives-----------------
6) The reason we are seeing this issue is because we have the below .lib files built with release runtime.uknowme.lib, iknowu.lib, blu.lib, rdd.lib, metl.lib.All these libraries are statically linked with exe.
Further our customer compiled all the above libraries in debug mode and then linked them , the application started working as expected.