munger
munger

Reputation: 107

R6034: An application has made an attempt to load the C runtime library incorrectly

I am getting this R6034 error when running program that I just updated (and cleaned) from VS2003 -> VS2008. To be more exact:

"R6034: An application has made an attempt to load the C runtime library incorrectly."

It seems to happed almost at the same place all the time when running. I have no really idea why but I tried some suggestions I found when googleing this. For example adding the msvc dlls, but that didn't work.

Any help on why this error occurs would be great. Thanks

Upvotes: 4

Views: 11208

Answers (2)

Patrick
Patrick

Reputation: 23619

The following test program:

#include <iostream>
#include <crtdefs.h>

void main()
{
std::cout << "Hello World" << std::endl;
}

Compiled using these commands (Visual Studio 2005):

cl /EHsc /MD /c test.cpp
link test.obj

Create the executable (TEST.EXE) and a manifest file (TEST.EXE.MANIFEST) that looks like this:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.4053' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

I didn't try this with VS2008, but this should probably work as well.

Hope this is enough to get you started.

Upvotes: 0

Patrick
Patrick

Reputation: 23619

Starting from Visual Studio 2005 you must refer to the C Run Time using a manifest file. Referring to the DLL's by just putting them in the path will give the above error.

The manifest file will look like this:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50727.4053' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

You can use the MT command to integrate the manifest as a resource in the application, but that's not mandatory. It's also allowed to have the manifest besides your application (as MYAPP.EXE.MANIFEST).

Upvotes: 2

Related Questions