views:

51

answers:

2

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

A: 

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

Patrick
okay, that makes somewhat sense. when i compile a new project using vs2008 <assemblyIdentity> ends up embedded in my .exe, but for this migrated project that part is not there at all. have i missed some project setting somewhere? or how do i get it in there for that project too?
mattias
I think that some of the C/C++ include files contain #pragma's that add a linker command so the linker generates the manifest. Look for /manifestdependency in the C/C++ include files. These should trigger the creation of the manifest file.
Patrick
didn't find anything like that. wondering if it is better to just make a new vs2008 project and move everything over by hand.
mattias
See my other answer for a test program.
Patrick
A: 

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.

Patrick
still does not work for my "migrated" project. but works when im making a new one. i will just remake the whole solution. marking your first answer as an answer since it is basically it. thanks!
mattias