Friday, October 23, 2009

Wine and Missing MFC42.DLL

Every once in a while I need to run a Window$ application. If the application at hand is a standalone application that does not require installation, I'll usually attempt to run it first with Wine, instead of launching a full blown WinXP virtual machine.

Using Wine is a no brainer:
wine /path/to/application.exe <command-line-arguments>
and if the file happens to have executable permissions (chmod +x ...) then it's even easier - just launch it like any other script or binary executable, by typing
/path/to/application.exe <command-line-arguments>
Last time I tried it I hit a problem:
err:module:import_dll Library MFC42.DLL (which is needed by L"Z:\\path\\to\\application.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\path\\to\\application.exe" failed, status c0000135
This means that a required DLL is missing - in this case it's MFC42.DLL. This specific DLL is needed for (older) GUI applications that use MFC, and it isn't part of Wine.

Whatever you do if this happens to you - don't try getting this DLL from any of the websites that Google will list when you search for it. Google marks quite a few of these sites as sites that can harm your computer. You have been warned.

Window$ users can get MFC42.DLL and other DLLs by installing the Microsoft Visual C++ Redistributable Package.

The recommended way of doing this under Wine is to follow the instructions on the Wine wiki:
  1. download winetricks:
    wget http://www.kegel.com/wine/winetricks
  2. make it executable:
    chmod +x winetricks
    (optional: place the file in a system directory such as /usr/local/bin)
  3. install cabextract:
    aptitude install cabextract
    (actually, I'm not sure it's necessary for fixing the MFC problem, but it's definitely recommended for fixing other Wine problems)
  4. run
    winetricks mfc42
The winetricks script has lots of other options for fixing a host of issues and installing a rather long list of third party packages that are not part of Wine.

Bottoms Up!

[25 Feb 2012] UPDATE: winetricks has been packaged in Debian/testing for quite a while - so I recommend that you don't install it manually as per steps 1 thru 3 above, but rather use one of the package managers to do it for you:
aptitude install winetricks

25 comments:

  1. Thanks, I was having this exact problem, following these instructions fixed it perfectly!

    ReplyDelete
  2. Thank you very much!
    Your post helped me to solve the same problem!
    ;-)

    ReplyDelete
  3. Hi, when I try to run winetricks, it says "command not found". I made it executable, but I don't know where it is, so I can't tell if it's in a system directory or not.

    ReplyDelete
  4. Well, you can use

    find ~/ -name "winetricks"

    to find it, but I guess it's right there in the same directory where you downloaded it to (maybe on your desktop? - firefox seems to default to that location)

    If you downloaded it with wget, as I suggested, then just run

    ./winetricks

    (note the ./) in the same shell you used to download the file in.

    If all else fails, try downloading the file again, but this time please use

    pwd

    in the shell to note where you are downloading the file to...

    Good luck.

    ReplyDelete
  5. Thanks, but it seems I somehow managed to install it correctly. Though the program I needed it for just returned errors (it was an installation program for a driver I needed).
    But thanks anyway, if I ever need help with this again, I know where to turn!

    Matt.

    ReplyDelete
  6. Your post is very useful to understand how resolve problem similar to mfc42.dll missing. Thank you very much!

    ReplyDelete
  7. Thank you! Outstanding, concise, effective fix for an all too common problem. Last time I had to deal with this it took ~2 hours to patch together. This time, your fix got me there in under 2 minutes. Again, THANK YOU!!!

    ReplyDelete
  8. Thanks very much. It actually fixed the problem. The only step I was missing was that winetricks was copied to the folder I was in.

    Thanks again.

    ReplyDelete
  9. Perfect that did the trick !

    Thanks a bunch !

    ReplyDelete
  10. Very cool. Perfect. Pierre

    ReplyDelete
  11. Excellent - Solved my problem.Great post!
    I'm using Debian Wheezy, & winetricks and cabextract are both Debian packages, so 'apt-get' did the job.
    Wine has really come of age now - time & again recently I've used it to run something only available as a Win .exe with 100% success - you couldn't say that a decade ago :-)

    ReplyDelete
  12. I won't be original probably, but thanks, it really helped! ;]

    ReplyDelete
  13. For a couple of years I was trying to get this to run in Ubuntu. I found this page and withing about 5 min it is running FAST!!!
    My hat is certainly off to you!!!!! Thanks you 100000 times. I love this program!!!

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Although "unknown" removed their post, I think it may be true that vc6redist86_enu.exe is no longer available from the MS download centre(I get a 404). Is this the same file:
    http://download.microsoft.com/download/vc60pro/update/2/w9xnt4/en-us/VC6RedistSetup_deu.exe ?
    Certainly worth checking if winetricks still works 100%

    ReplyDelete
  16. http://askubuntu.com/questions/169218/winetricks-cant-install-mfc42

    ReplyDelete
  17. If you can make a video of this process it would be a lot easier. I just want to play a game and it is too complicated for me. thnx anyways!

    ReplyDelete
  18. Thank you very much, it solved my problem.

    ReplyDelete