1

The title is pretty straightforward - I can't get anything at all to run when building in x64 and I get a message box with this error code. Do you know what may be the problem here?

Philip
  • 373
  • 2
  • 11
  • Turns out this was only happening in debug mode, so I was able to figure out that one of my dll's was 32-bit only. Once I replaced it everything was good. – Philip Jan 22 '13 at 15:51

2 Answers2

2

This is STATUS_INVALID_IMAGE_FORMAT, you can find these error codes listed in the ntstatus.h SDK header file.

It is certainly strongly correlated with building x64 code. You'll get this status code whenever your program has a dependency on 32-bit code, particularly in a DLL. Your program will fail to start when it tries to load the DLL at startup, a 64-bit process cannot contain any 32-bit code. Or the other way around, a 32-bit process trying to load a 64-bit DLL.

Review all the dependencies for your program, particularly the import libraries you link. Everything must be built to target x64. You can use SysInternals' ProcMon utility to find the DLL that fails to load, useful in case this is a DLL Hell problem.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thanks for the direction - I had a version of msvcr100d.dll that was not 64-bit compatible. I realized after posting this that the Release version of the exe was running fine. I replaced the file with the correct one and everything is good now. – Philip Jan 07 '13 at 18:41
  • 1
    Linking to http://stackoverflow.com/questions/21356654/vs2012-error-the-application-was-unable-to-start-correctly-0xc000007b/21356714#21356714 which mentions Dependency Walker which helped me to find the referenced 64bit library. – MiroJanosik Apr 08 '16 at 09:09
1

Just an addition to the correct answer above: also check you .manifest-files (resp. #pragma comment(linker,"/manifestdependency...) and make sure that you have processorArchitecture='x86' for 32-bit and processorArchitecture='amd64' for x64 code.