Tuesday, September 8, 2009

Installing Wine on Mac OS X

Part 1: Install MacPorts

MacPorts is a package manager that makes installing open source programs much easier. In particular, trying to install a large program like Wine without the help of a package manager would be tremendously difficult. Fortunately, MacPorts itself is simple to install.

  1. On the MacPorts website, go to the Download and Installation page and download the appropriate "dmg" disk image for your computer.
  2. Double-click the file you downloaded, and double-click the .pkg file to run the installer. You're almost done!
  3. Open up the Terminal and copy and paste the following into it. Remember not to include the dollar sign ($) at the beginning.copy all as a one line..

$ echo export PATH=/opt/local/bin:/opt/local/sbin:\$PATH$'\n'export MANPATH=/opt/local/man:
\$MANPATH | sudo tee -a /etc/profile

The Terminal will ask for your password: this is the password to the
Admin account on your computer. As a security measure, the Terminal
does not display anything as you type, not even asterisks (*). Type your password anyway, and press enter. If you ran the command correctly, the Terminal should respond with:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/man:$MANPATH

If you didn't get that response, it might be because the Admin account doesn't have a password set. Setting a password is required.
4. Close the Terminal. MacPorts has been installed!

Part 2: Install Wine Using MacPorts

Let's start using MacPorts right away! To tell MacPorts that you want it to install Wine for you, all you have to do is open up the Terminal again and enter this command (without the $):

$ sudo port install wine

You may be asked for your Admin account password again. The Terminal will start displaying lots of information. This is absolutely normal — MacPorts is just keeping you updated on what it's doing. This flow of information will be your guide to let you know whether or not the computer is still working. It will take a while for the install to finish: at least half an hour. As long as the Terminal keeps on giving you more information about what it's doing, don't interrupt it. Feel free to leave and do something else while the computer is installing Wine. When the Terminal stops giving you more information and is ready for another command, Wine is installed and ready to go!

Note: If you get an error message at this step that reads error: C compiler cannot create executables, it usually means you forgot to install Xcode. See the requirements.


Part 3: Install Windows Programs Using Wine

To install a Windows program, first download the installer file: it should end with .exe. Remember the location you put it, and open up the Terminal again. cd to the location, and use ls to make sure you can see the installer file. Once you are in the correct directory, run the installer through Wine by running the following command in the Terminal:

$ wine $INSTALLER.exe

Where $INSTALLER is the name of the installer file. For example, if the installer file is named setup.exe, you would run:

$ wine setup.exe

X11 will open (if it isn't already), and soon you will see a regular graphical Windows installer. Click through it, and you're done!

Part 4: Run Windows Programs Using Wine

Open up the Terminal and run this to get to your Program Files folder:

$ cd ~/.wine/drive_c/Program\ Files/

Run ls to see what programs you have installed. Pick a program, and enter its directory using cd. (If the folder has a space in it, you must type a \ before the space. For example, Program\ Files. If you're having problems, try using tab autocomplete.) There should be a file that ends in .exe: this is the program file. Type this into Terminal:

$ wine $PROGRAM.exe

Where $PROGRAM is the name of the .exe file. X11 will open (if it isn't already), and the program will pop up, ready to use! It will probably open fullscreen: to reduce it in size, go open the Window menu from the Mac OS X menu bar, and select Zoom Window. You can then resize the program normally. Enjoy using Windows on your Mac, freely and legally!

Keeping Wine Up to Date

Wine is an open source program. That means that programmers around the world are continually improving it, adding new features and squashing bugs. If you don't update Wine, though, it will never get those improvements, so it's generally a good idea to check for updates every so often. We can use MacPorts to keep Wine up to date: it's easy! Just run this command:

$ sudo port selfupdate && sudo port upgrade outdated

Once again, you will need to enter your Admin account password. With this command, MacPorts will first update itself, if any updates are available. It will then find all the outdated software it knows about (including Wine) and upgrade them all to the latest version. Checking for updates isn't strictly necessary, as Wine runs quite well currently. However, it's a good idea to run this command every few months or so.

Uninstalling Wine and MacPorts

If you try Wine and you don't like it, uninstalling it is easy. Just run this command:

$ sudo port uninstall wine

And MacPorts will helpfully remove Wine from your computer. However, in order to install Wine, MacPorts also had to install many other small programs that Wine relies upon to work correctly. (That's why the install process takes so long!) If you want to remove these as well, it's simplest to just delete your entire MacPorts installation with the following command:

$ sudo rm -rf /opt

That command should remove everything that you installed in this tutorial, including MacPorts, Wine, and all the other programs MacPorts installed to get Wine to work correctly.

So why would you ever use the first of those two commands, rather than the second? Well, MacPorts can install a lot more than just Wine. There are a whole bunch of nifty programs you can easily install using MacPorts, such as GraphViz (a very swanky graphing tool), Battle for Wesnoth (a turn-based strategy game), and GIMP (an image editor, like Adobe Photoshop). And just like Wine, every program available on MacPorts is free and open source. Even if you decide Wine isn't for you, MacPorts might have something else you might like. Take a look!





1 comment:

Anonymous said...

A decent tutorial, but there's a problem here,

"Enjoy using Windows on your Mac, freely and legally!"

You aren't using Windows. Using Windows would require a Windows license, which Wine doesn't come with. Wine lets you use (some) Windows programs, not Windows.

BlogCatalog

Technology Blogs - BlogCatalog Blog Directory