Saturday, June 12, 2010

Ubuntu 10.04: IrfanView and Other Portable Apps via Wine

According to Tom Wickline, the process for installing IrfanView 4.23 on Ubuntu 8.04 was just a matter of installing winetricks and MFC42.dll and then installing IrfanView.  I wasn't sure how to do each of those steps, and I wasn't using quite the same setup as he was.  This post traces through my own installation process.

I was using Ubuntu 10.04 (Lucid Lynx).  I had just downloaded IrfanView 4.27, and thought I would try to install that latest & greatest version.  Also, unlike Tom's system, mine was not "a clean configuration directory, with no other applications or games installed."  According to Ubuntu's System > Administration > Synaptic Package Manager, I was using Wine 1.2.

My first hurdle was to figure out how to install MFC42.dll.  A WineHQ webpage said that I could get MFC42.dll from Microsoft or via winetricks.  They said I might already have gotten winetricks installed during my Wine installation, but they also said that I could run it even if it wasn't installed; I would just have had to type "sh winetricks" instead of just "winetricks" to run it.  I checked Synaptic.  Sure enough, there it was.  The purpose of winetricks seemed to be to add Windows-friendly support files so that Wine would run Windows programs.  That sounded about right.  The winetricks webpage listed MFC42.dll among the files that it was prepared to help me with.  I went ahead and typed "winetricks mfc42.dll."  That ran and appeared to change some settings.  I went into the wine subdirectory under my Ubuntu user folder:  File System/home/ray/.wine/drive_c/windows/system32.  Tyler Style had said that it needed to be there, but it wasn't.  Amusingly, he had posted that a few months earlier in response to my previous attempt, a year earlier, to get IrfanView running in Ubuntu.  Well, I thought, maybe MFC42.dll had known what it was doing when it installed itself; maybe Tyler was wrong as to the location where it would be found.  The other thing he said that I needed to do was to go into Applications > Wine > Configure Wine > Libraries tab and register MFC42.dll there.  I typed mfc42.dll into the "New override for library" box, at that location, and clicked Add.  It seemed to accept it:  it listed "mfc42 (native, builtin) as an Existing override.  I clicked Apply > OK.

This was fine, for whatever it was worth, but it didn't add IrfanView to my program menu.  To install IrfanView, I had gathered somewhere that I needed to type "wine iview427_setup.exe" to install IrfanView.  I tried that.  It replied with this:

wine: cannot find L"C:\\windows\system32\\iview427_setup.exe"
That raised two questions, which may be summarized as "why not?" and "so what?"  I didn't know why the error message had put that L in front of the C, but whatever; I had since discovered that, in Windows, IrfanView would install as a standalone program, and had therefore moved it to a different partition where I kept all of my Windows standalones (so that I wouldn't have to reinstall them whenever I had to reinstall Windows, but could instead just copy the whole folder to drive D (or whatever) on the new computer.  In other words, I wondered whether I could skip the installation; I wondered whether Wine could run portable or standalone programs.  According to MoebusNet, it could, and one way to make it do that was to download and install PortableApps to the USB drive where you were going to keep your portable programs.  In my case, I wasn't going to keep them on a USB drive; I was going to keep them in a folder on my hard drive.  I wasn't sure how that would work, but I gave it a try.  I downloaded and ran the little 2MB PortableApps Platform.  They said it was self-contained -- PortableApps was, itself, portable -- so I wondered if I could install it on the folder on my hard drive where I kept my other portable programs.  After a brief search, I decided the best way to find out was just to try it.  So when it came time, in the installation process, to choose the install location for PortableApps, I named that folder as the destination.  When the installation finished, in Windows Explorer I copied my IrfanView portable folder to the PortableApps folder.  (I kept a copy in the original location so that it would be available outside of Portable Apps as well.  I thought I would probably prefer to run it that way from my WinXP boot.)  I deleted iv_uninstall.exe from this copy, since I didn't want the uninstaller to show up in PortableApps.  I created a shortcut to PortableAppsPlatform.exe and put that in my Start Menu.  I started up PortableAppsPlatform and, following instructions, clicked on its Options > Refresh App Icons.  I clicked on the IrfanView icon and, sure enough, IrfanView started up.

So now that I had acquired this lovely knowledge about PortableApps, it was time to get back to what MoebusNet had started telling me, about running portable apps in Ubuntu via Wine.  I typed this:
wine "/media/DATA/Standalones/PortableApps/PortableApps.com/PortableAppsPlatform.exe"
and that worked:  IrfanView started up.  So the concept seemed to be that any portable app that I would put into a folder on the same level as the PortableApps.com folder would show up when I ran that command.  So I could make a single PortableApps menu pick for Ubuntu, and it would lead, via PortableApps, to any portable application program that I would set up that way.  I set up a launcher for that wine command by highlighting, right-clicking, and copying it into the Ubuntu Applications menu:  right-click on Applications and choose Edit Menus > Applications > Accessories > New Item.  Name it PortableApps, paste the copied command into the Command box, and Comment it as "Launch portable Windows applications."

This was all wonderful.  But when I tried to play a .wav file in IrfanView, I was still getting the same error message from the previous year, the one that Tyler Style had tried to help me with.  The message read as follows:
IrfanView
Error:  Windows can't play this file!
Windows error text:  Invalid MCI device ID.  Use the ID returned when opening the MCI device..
You can try to install additional video/audio codecs from this site:
http://www.fourcc.org/indexcod.htm
or try the DirectShow option in 'Properties->Video'
The fourcc.org/indexcod.htm webpage seemed to offer video but not audio codecs.  Some Ubuntu documentation pointed me toward the Ubuntu restricted extras repository.  I thought I had already set myself up for everything I could get from there, but the documentation was saying, "Installation only works completely and properly when done from the command-line Terminal. The entire package will not usually install completely from within a Package Manager."  So possibly Synaptic had not brought me all of the codecs I needed.  I killed IngrfanView and then, obeying the documentation, I typed this:
sudo apt-get install ubuntu-restricted-extras
but it said I already had the newest version.  I could have tried completely removing and reinstalling ubuntu-restricted-extras, but that sounded like it could lead to other difficulties.  Besides, another post made it sound like the codecs might actually be in Medibuntu, which I had also installed.

There were two other things to think about.  One was that I might just try a different audio player.  I posted a question on that.  The other was that I maybe I should take a shot at that actual error message.  What did "Invalid MCI device ID" mean?  Turns out I had posted a bug report on it the previous year.  I posted an update to that bug report.

Meanwhile, in response to the question about an alternative audio player, I got a suggestion to try an older version of IrfanView (namely, 3.98), or to try mpg123 if my reason for wanting IrfanView was to enable skipping to the next file in a folder with just one keystroke.  IrfanView 3.98 dated from 2005, so I would be missing out on some newer functionality.  It didn't seem to be available on the official IrfanView site, but I found numerous other locations for it.  It was a bit harder to find the plugins for version 3.98, but eventually I did.  I installed 3.98 and its plugins on a Windows XP machine and then moved the installed folder over to the Ubuntu machine.  I deleted the previous IrfanView folder from the PortableApps folder, and put this new IrfanView 3.98 folder into PortableApps in its place.  (This time, I didn't keep a copy outside of PortableApps, since I didn't plan to run 3.98 in WinXP.)  Once again, I deleted the Uninstall.exe file from this IrfanView 3.98 folder.  I went to Ubuntu's Applications > Accessories > PortableApps > Options > Refresh and then clicked on IrfanView.  It opened up.  I went to Help > About.  Sure enough, I was now running version 3.98.  To test it, I hit Print Screen.  This opened Ubuntu's Save Screenshot dialog.  I clicked Copy to Clipboard, moused to IrfanView, and hit Ctrl-V.  Sure enough, I had the screenshot in IrfanView.  I tried cropping it (left mouse click / drag / release, Ctrl-Y), set View > Display Options > Fit Images to Window, and, sure enough, IrfanView was functioning normally.  Cool!

To try IrfanView's audio functioning, I navigated to a folder containing several .wav files, double-clicked on the first one, and it played -- in Ubuntu's Totem Movie Player.  Oops.  I right-clicked on the .wav, but Ubuntu wasn't listed as a possibility for the program to play it in.  I went back to PortableApps and started IrfanView again.  I went into its Options > Properties -- but, of course, I had already set those.  So, a problem:  could I get Ubuntu to treat IrfanView as the default viewer or player for a filetype?  My first search didn't turn up much.  PortableApps had a live support chat, but no joy for me there, so I posted a question on it in a PortableApps forum.  Then, resuming my tinkering, I right-clicked on the .wav again and chose Open With > Other Application > Wine Windows Program Loader, but that gave me "Error:  There is no Windows program configured to open this type of file."  Well, I had definitely configured IrfanView to do so, but maybe Wine didn't agree.  I tried a search for that error message, and followed one particularly painful thread from that search.  Somewhere along the way, I got the idea to try Ubuntu's Applications > Wine > Configure Wine > Applications.  With Windows XP as the version of Windows specified at the bottom of the dialog, I clicked on Add Application and navigated to the folder where I had put PortableApps; and in there, I navigated to the IrfanView folder, selected i_view32.exe, and clicked Open > OK.  Now I went back to the original Ubuntu right-click on the .wav, selected Open With > Wine Windows Program Loader . . . and still got the same "no Windows program configured" error.

I had forgotten the option of installing IrfanView as an Ubuntu application via Wine.  Following my steps from a year earlier, I navigated to the IrfanView 3.98 folder and typed "wine i_view32.exe."  But no, that wasn't right; that just ran the portable version.  That command-line approach wasn't necessary anyway; I discovered that I must already somehow have set up Wine to run .exe files automatically, apparently following advice like that provided by a relevant Community Documentation page.  All a bit puzzling.  I continued playing and posting on it, trying to dig my way out.

Meanwhile, I experimented with mpg123.  Some time had passed, and I couldn't remember if I had already installed it, so I just typed "mpg123" at the Ubuntu command line.  This gave me an odd error message:
The program 'mpg123' is currently not installed.  You can install it by typing:  sudo apt-get install mpg321.
What was odd was that the installation line said mpg321, not mpg123.  I checked Synaptic.  It confirmed that I didn't have mpg123 installed yet, and it also showed me a program called mpg321 on the next line.  The description of the latter characterized it as an "mpg123 clone that doesn't use floating point."  Apparently someone at mpg123 decided that mpg321 was a superior alternative, and thus gave me that command line suggestion to use mpg321 instead.  Just to be sure, I did a search and got the impression that mpg123 began as nonfree software, so mpg321 was prepared as a free alternative and it just became more popular.  I installed both of them in Synaptic, but after playing around with them for a half-hour or more, I was still not getting playlists to work properly.

I found a page listing top Linux music players.  I looked at the webpages for several on that list, but none of the six or eight pages I looked at provided a simple explanation of how the players actually worked -- of whether, to cite an example, you could hit the 6 key on the numeric console at the right end of a standard keyboard to move on to the next file, as you could do in Winamp.  From that list, in the name of trying something rather than nothing, I installed Audacious.  It was a nice enough player, but it did not have the ability to delete a file that I was listening to, as IrfanView did.  It was also not as responsive:  IrfanView would stop immediately when I told it to, so that I could mark a file for resorting or other handling; Audacious would continue on for maybe a second or so, which is not much except when it results in the program's moving on to the next file, which was not the one that I wanted to delete, re-listen to, or otherwise handle.  I decided, once again, that what I wanted was undeniably IrfanView, until further notice.

By this time, Ringi had replied to my latest post in that thread.  It seemed that s/he was doing just fine with the latest version of IrfanView in Ubuntu.  Since there seemed to be no need for 3.98 after all, I deleted the IrfanView 3.98 folder from PortableApps and replaced it (again, without the uninstall.exe) with a copy of 4.27.  Ringi asked whether I had installed IrfanView's plugins, and that was a good question; I was not sure.  Actually, by now I wasn't even sure I had actually installed IrfanView via Wine; it wasn't appearing in Applications > Wine > Programs.  Returning to my notes at the start of this post, I decided that the PortableApps thing was a dead end, at least for purposes of getting IrfanView to run the way I wanted.

I went back, specifically, to the advice (above) that I needed to type "wine iview427_setup.exe" to install IrfanView.  In Terminal, I navigated to the original setup folder (i.e., not the unpacked, ready-to-run standalone folder) where I had stored iview427_setup.exe and irfanview_plugins_427_setup.exe.  I typed that  Wine command:  "wine iview427_setup.exe."  It said, "err:module:import_dll Library MFC42.DLL (which is needed by L"D:[path]\iview427_setup.exe") not found."  So, OK.  I had not correctly installed MFC42.DLL after all.  Following the Winetricks instructions, I typed "sh winetricks mfc42.dll."  I got an error:  "Can't open winetricks."  I verified, in Synaptic, that I did have cabextract installed.  Synaptic also confirmed that I had winetricks installed.  Nonetheless, following those instructions, I typed "wget http://www.kegel.com/wine/winetricks."  It ran.  I tried "sh winetricks mfc42.dll" again.  This time, it said, "Unknown arg mfc42.dll," followed by a list of the packages that it did have.  Oops:  just plain mfc42, not mfc42.dll.  I retried:  "sh winetricks mfc42."  It ran without error.  So, interesting:  it seemed that Synaptic (or whatever approach I had used previously) had not done the job of installing winetricks properly.  Now I got a dialog for "VCRedist Installation."  I okayed through that; something ran in Terminal; and it concluded with this statement:  "Install of mfc42 done.  Winetricks done."  Cool.  I had finished the mfc42 part.  Now back, once more, to "wine iview427_setup.exe."  This gave me the IrfanView Setup dialog.  I set it to install for all users in C:\Program Files\IrfanView\.  It completed, and IrfanView was up and running.  I killed it and typed "wine irfanview_plugins_427_setup.exe."  That ran OK, and now I had an IrfanView entry in Applications > Wine > Programs.  I started IrfanView and set its options, including naming it as the default handler for all audio files.

So IrfanView now seemed properly set up for sure.  In IrfanView, I did a File > Open.  It was listing only image files, but I changed it to show all files, and then tried to play one of the .wav files in that folder.  It gave me the "Error:  Windows can't play this file!" message again, same as before.  I killed IrfanView, double-clicked on a .wav file in Nautilus, and the file played -- in Totem!  It certainly appeared that I had installed IrfanView correctly -- at least once, if not multiple times -- and yet it was still not functioning properly for me in Ubuntu.  I returned to a Wine bug report that I had started to file a year earlier.  I didn't know how to file bug reports, but I gave it a whirl.  The concept seemed to be that you get a debug trace on the uncooperative program.  In this case, that seemed to call for going to the folder where I had installed portable IrfanView and running the following command:

WINEDEBUG=+relay,+seh,+tid wine i_view32.exe &> /tmp/output.txt

That opened IrfanView and waited while I repeated the steps I had taken:  open a .wav file, get a repeated error message, etc.  When I closed IrfanView, the output file was there.  But when I looked in it, it only contained repeated instances of this message:  "fixme:mciwave:MCIWAVE_DriverProc Unsupported yet command [2115]."  That last number changed, in each of the six repetitions of that message:  2115, 2114, 2132, 2114, 2132, 2132.  Maybe that was all it was supposed to say.  Whatever.  I attached the output.txt file to the bug report and sent it off.  Meanwhile, I posted a link to this note in the discussion thread, in case Ringi or someone else felt like reviewing it and possibly detecting what I had done wrong.

5 comments:

raywood

I posted a bug report in the IrfanView forum at http://en.irfanview-forum.de/vb/showthread.php?6598-Invalid-MCI-device-ID-IrfanView-under-Wine-in-Ubuntu&p=30625#post30625

Simon

I bet "fixme:mciwave:MCIWAVE_DriverProc Unsupported yet command" means that the WINE developers haven't yet implemented the needed mciwave functionality.

Anonymous

According to the hint by Haukew on_http://www.ubuntu-forum.de/artikel/3781/IrfanView-mit-wine-benutzen.html_ I just placed the mfc42.dll file in the same folder as the iview_410.exe file, then executed the install procedure with wine. Works perfect. Notice: I used IrfanView version 410 to avoid trouble with the new IrfanView toolbar that comes with version 427.
Greetz, Jan.

emarkay

Have you gotten 4.27 or 4.28 to work; with the "Paint" portion able to save its edits on the image?
See WINEHQ page on Irfanview for details:
http://appdb.winehq.org/objectManager.php?sClass=version&iId=7834

raywood

A later post reports some progress on IrfanView audio playback with the aid of Cameyo.