3

I have a mfc c++ project on vs2010. I am able to build it in both debug & release mode , but when I run it in debug mode, it gives the follow mfc100d.dll error. I have also installed C++ runtime environment vcredist_x86.exe still the issue is not fixed. Also I have set the Multi-threaded DLL (/MD) as the Runtime Library. How do I fix it ?

enter image description here

foobar
  • 2,887
  • 2
  • 30
  • 55

2 Answers2

5

The d suffix on the name of the DLL indicates that it's a debug version of the runtime DLL. That's confirmed by the fact that you say the problem happens when you try to run the debug version of the application.

By default, and for good reason, debug builds link to debug versions of the runtime libraries. These versions are not redistributable, and thus are not getting installed with the redistributable package (vcredist_x86.exe). That's not normally a problem: you aren't supposed to ship debug versions of your application.

The non-redistributable debug libraries are, however, installed with Visual Studio, so the debug version of your app should run fine on the computer you used to develop and build it. Which is likely the same computer you're going to use to debug it.

Also I have set the Multi-threaded DLL (/MD) as the Runtime Library.

Three important things to note about this:

  1. You have to make sure that you set it for the correct build configuration (i.e. "Debug").

  2. This is not recommended. Debug builds of your application should use the debug versions of the runtime libraries. They do a lot of things behind the scenes that help you to catch bugs. That's why they exist. If you don't want a dependency on the debug version of the runtime libraries, compile and distribute a Release build of your application.

  3. That switch changes the version of the C/C++ runtime library that your application links to. The DLL you're getting the error message is an MFC runtime library.

    The MFC headers test whether the _DEBUG preprocessor symbol is defined in order to determine which version of the runtime libraries should be linked in. Since _DEBUG is defined automatically in a debug build, it's linking in the debug version of the MFC libs.

    To change that, you're going to need to do a lot of manual labor, undefining this symbol before you include the MFC headers, and then re-defining it afterwards.

    Alternatively, you can statically link to MFC, which is a setting in your project's properties. But do be careful with this: you'll end up inadvertently mixing versions of the CRT, which can leave you in a world of hurt. Better to just ship release versions and keep debug versions for internal debugging.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • Actually I am not the one who developed the project. It's being assigned to me for fixing some issues. And obviously it was not developed on my machine. So is there no way I can debug this project on my machine ? – foobar Jul 22 '13 at 06:48
  • @smilepleeeaz Install Visual Studio. How did you plan to debug it otherwise? – Cody Gray - on strike Jul 22 '13 at 06:51
  • I am using Visual Studio 2010, that's where the issue is coming in debugging it. – foobar Jul 22 '13 at 06:54
  • If you have Visual Studio installed and you're still getting that message, something is badly wrong with your computer configuration. You need to get your computer stable first, then re-install Visual Studio. – Cody Gray - on strike Jul 22 '13 at 07:00
  • well I debug other mfc projects on the same computer, but such issue never comes. – foobar Jul 22 '13 at 07:09
  • 1
    My crystal ball says he's got the Express edition. Not sure why it is saying that. – Hans Passant Jul 22 '13 at 11:55
  • I reinstalled the microsoft sdk and this fixed it. So may be some dlls were corrupted. – foobar Jul 25 '13 at 07:38
0

Reinstalling the Microsoft SDK fixed this error.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
foobar
  • 2,887
  • 2
  • 30
  • 55