Thursday, February 08, 2007

Compile WINE on Mac OS X Tiger

The WINE is more practical than ever on Mac OS after the Apple Inc. shifted to Intel platform.

There was Darwine (maybe I should say IS, but I haven't seen any update from Darwine for over half a year now). Darwine is meant for PowerPC Macs - because the lack of binary compatibility, Darwine needs a PC emulator to run Windows applications on PowerPC Macs. (It still better than running a virtual Windows - you don't need the Windows license to run WINE or Darwine.

Things are much less complex now, thanks to the moving to the Intel CPUs. At the core, a Mac is binary wise compatible with a PC running Windows. All you need to run (most) Windows applications on a Mac OS is WINE.

However, there are not many doc out there telling people how to build WINE on a Mac.
I guess it is TOO easy for the hard-core WINE "drinkers" and there is no need for a step by step doc for building it. However, a lot of Mac user are not as CMDLUI (Command line User Interface) as Linux users, and I figure it may be helpful if we have a (brief) doc helping users to build WINE on Mac OS X.


Let me try to make it easier for you here (Everything is done on Mac OS X 10.4 Tiger).

1) you will need X11. Remember that WINE is written for Linux originally, and it use the de facto GUI standard - X11. While Mac OS X comes with X11 (Mac is based on Darwin - a variance of FreeBSD), it is not the default Apple GUI (which is AQUA). You can check if you have X11 by open the Finder, under Applications, Utilities, you an app called X11 sitting there. If you don't see it there, you need to install it by pop in the Mac OS X installation DVD, run the Optional Packages, and select X11 in it.

2)You will need Xcode with X11 SDK. These are the tools you use to compile and build WINE. It is freely available to Mac Users (it is GCC 3.3 and 4.0 at the core). One thing to note though, you need Xcode 2.4.1 or up. The Xcode came on the DVD will give you Syntax error ( unknow structure x86_DEBUG_STATE32) while compiling mach.c.

A good thing about Xcode is it is so easy to use, it nearly make you forget you are "developing" something. Don't be scared if you never wrote any program, it is really simpler than Microsoft Office.

3)You need Freetype 2.05 or up. You can either use a package (Macport/DarwinPort or fint), or you can download the source and build your own. I prefer download and build my own (probably because of my Linux background).

4)You will need Fontforge. Again you can chose to install a package or build it from source. Again, I prefer build from source.

5) You will need to change the PATH before you start ./configure of WINE, or it will not be able to find X11 and freetype. export PATH=/usr/X11/bin:$PATH.

6) now some basic things that Linux guys will laugh at me for writing about it. you now download wine, extract it to a directory, go into that dir and run "./configure"

7) make sure ./configure shows you no error, at the end it tells you now run "make depend && make". do so.

8) if everything returns clean, you should install wine to /usr/local/ by running make install.

9) now you can test your wine by running ./wine notepad.exe (you need to copy the notepad.exe from a real Windows machine).

10) optional but suggested: add "/usr/local/bin" to your PATH.

31 comments:

Zee said...

Why not just use Darwine's build script instead? It does everything for you and leaves a nice .dmg that can be installed instead. http://thisismyinter.net/?p=11 goes over how to set that up.

Sander said...

I'll wait for the all-in-one package installer I can double-click. When that arrives, I'll pay for it.

Anonymous said...

How about just posting binaries with an installer :)

Dan said...

How about just posting the binaries with an installer :)

Anonymous said...

This is awesome. Is there any any way to simplify the process further, possibly making a DMG? Just s thought...

juancn said...

It would be nice if you could post a binary version somewhere. That would save the rest of us a lot of problems. (I know it's not your responsibility, but thought I might ask anyway!)

Karl L. Gechlik said...

Thanks from your friends over @ AskTheAdmin

Anonymous said...

do not test wine by running /usr/local/bin/wine notepad.exe

Please make sure you run "winecfg" first. This installs the default home directory for your fake Windows system.

/usr/local/bin/winecfg

Anonymous said...

You are a clueless mac user if it has taken you this long to work out how to compile a linux app.

paytonrules said...

Has anybody ever complained about the following messages after these directions:

Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.

Mind you I've installed freetype and my XServer is running.

The Unix Geek said...

wow. the make depend && make step sure takes a looooooonnnnggg time :P

The Unix Geek

Anonymous said...

hi, I don't understand the part where you say you have to configure the PATH, I think thats whats throwing off my install.

Anonymous said...

This is what I got trying ot urna n app, install and compiles went fine, followed directins, what's wrog, how can I fix this:
wine: creating configuration directory '/Users/rjg/.wine'...
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:wgl:process_attach X11DRV or GDI32 not loaded. Cannot create default context.
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
wine: '/Users/rjg/.wine' created successfully.
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
err:imagelist:ImageList_ReplaceIcon no color!
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.

Anonymous said...

A thousand thanks for this tutorial. Made things clear what I needed to download to get things running.

Alan Tan said...

For the question posted by Anonymouse on Aug 07, 09:02:00 PM.

I think you probably have 2 problems in your system.

1) it seems your X11 server seems not started. in Finder, go to Application -> Utilities and launch the X11 there. You should sees "xterm" window show up and try do the rest from this window which should have DISPLAY configured for you already.

2) it seems your freetype is not configured right. Please check if you have /usr/X11R6/include/freetype2 dir, if not, you need to install freetype.
The one came with Mac OS X is too old and cannot be used with WINE.


paytonrules, your problem is also seems Freetype related.

Jesse said...

I've finished compiling, but when I try to install, I get the following message:
mkdir /usr/local/include
mkdir: /usr/local/include: Permission denied
make[1]: *** [/usr/local/include/wine/windows/ddk] Error 1
make: *** [include/__install__] Error 2

Alan Tan said...

Hi Jesse,
the error message "Permission denied" suggest you may not be "su"ed to root, instead you run the command as your own id.
Try "sudo su -" and if asked for password, type in your own password. This will make you root and hence can do (pretty much) everything you want.

then re-try the "mkdir /usr/local/include" and commands follow it.
Good luck.

Jesse said...

Ah, thanks so much, dude! Why didn't I think of sudo? I had just learned about that, too!

Hilbert said...

Hello! I read this article! Big thanks to author, very interesting. Write more.

Reijo Vosu said...

hello,

i have problem. It says that he doesnt find X or FontForge.

I putted the right path /usr/X11R6/bin and I installed fontforge with package.

any ideas?

Anonymous said...

Someone please make an all in one, I am sorry if I sound dumb but this is beyond me...

lfom said...

First of all, thanks for the tutorial and the info.

I was trying to build Darwine on my MacBook Pro running Tiger but run into problems, like most people here. I had the XCode and the X11 SDK installed, but could not get it to compile. To fix it, I had to download and install FontForge (there are binaries for Intel and PPC Mac's), and then create a simlink of the X11 SDK folder in the /usr/local folder:

cd /usr/local/
sudo ln -s /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/ X11R6


Then I could get a running Darwine but had problem with fonts, that I fixed using this tutorial (there are binaries of the latest Darwine builds for download too, for people that don't want or can't build it): http://thisismyinter.net/?p=23.

Maybe there is an easier way to do this, as explained in the Winehq wiki for Mac OS X: http://wiki.winehq.org/MacOSX/Building, but I didn't get the FIXME instructions (I guess something is missing).

Thanks again and kudos from Brasil! =)

lfom said...

First of all, thanks for the tutorial and the info.

I was trying to build Darwine on my MacBook Pro running Tiger but run into problems, like most people here. I had the XCode and the X11 SDK installed, but could not get it to compile. To fix it, I had to download and install FontForge (there are binaries for Intel and PPC Mac's), and then create a simlink of the X11 SDK folder in the /usr/local folder:

cd /usr/local/
sudo ln -s /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/ X11R6


Then I could get a running Darwine but had problem with fonts, that I fixed using this tutorial (he has DMG with the binaries for download also for people that don't want or can't build them): http://thisismyinter.net/?p=23.

Maybe there is an easier way to do this, as explained in the Winehq wiki for Mac OS X: http://wiki.winehq.org/MacOSX/Building, but I didn't get the FIXME instructions (I guess something is missing).

Thanks again and kudos from Brasil! =)

djidji said...

if you installed freetype2 by ways of a package manager, i.e. fink or macports make sure you symlink all libraries from the tree of the package manager to /usr/local/lib, i.e.:
sudo ln -s /opt/local/lib/freetype.* /usr/local/lib/*
for macports.
Took me the better part of the day to figure that out :-(
this fixes the 'wine cannot find freetype' errors

Austin said...

You don't need to copy notepad.exe from windows. Wine comes with its own implementation.

Javier said...

hey guys i have try every thin and nothing work so plz if some one can help me step by step i will appreciated this is what coming up at the last don't know some help

Font metrics: 100.0% done
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
http://www.freetype.org
Failed to open the service control manager.
err:psdrv:PSDRV_PPDGetNextTuple Line too long.
err:psdrv:PSDRV_PPDGetNextTuple Line too long.
err:psdrv:PSDRV_PPDGetNextTuple Line too long.
To use WINEPS you need to install some AFM files.
fixme:winspool:AddPrinterW DocumentPropertiesW on printer 'L"AdobePDF7"' fails
err:psdrv:PSDRV_PPDGetNextTuple Line too long.
err:psdrv:PSDRV_PPDGetNextTuple Line too long.
err:psdrv:PSDRV_PPDGetNextTuple Line too long.
To use WINEPS you need to install some AFM files.
wine: Unhandled alignment at address 0x0 (thread 0009), starting debugger...
wineprefixcreate failed while creating '/Users/mariatcruz/.wine'.
clientYsessionidWentriesVobjectXbehaviorZunregister_"com.apple.sessionDidMoveOffConsoleZWineHelperRCB°

Alan Tan said...

Hi Javier,
Have you checked djidji's comment above?
he(or she) said...
if you installed freetype2 by ways of a package manager, i.e. fink or macports make sure you symlink all libraries from the tree of the package manager to /usr/local/lib, i.e.:
sudo ln -s /opt/local/lib/freetype.* /usr/local/lib/*
for macports.
Took me the better part of the day to figure that out :-(
this fixes the 'wine cannot find freetype' errors

Eliot said...

Great tutorial! It really helped a lot. However, I've got wine working but I'm still getting an error when I try to open some programs (I believe it might be openGL programs that cause it - many simple Windows programs open just fine.) The program doesn't open and I get the following error:

X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 129 (Apple-DRI)
Minor opcode of failed request: 2 ()
Value in failed request: 0xa0000b
Serial number of failed request: 123
Current serial number in output stream: 123

I'm on OS X 10.4.11... do you think it may be a graphics problem? Do you have any ideas? Thanks!

Drew White said...

Hi sorry this is still unclear on some points for me, and I have used linux in the past... though not in a very advanced manner.

The way you have explained about changing the PATH (Point 5) I just can't understand. Maybe it's the way it is written but I am very unclear about it. If the OP or someone could explain this step I will be able to move forward thanks!

Anonymous said...

Not every Mac user understands coding. I'm one of the ones that doesn't - these instructions might be baby steps for many people but for some of us the whole thing might as well be written in a foreign language we don’t understand.
All I want is to get Wine, or something that does what Wine says it does, on to my Tiger G5 PPC so I can open exe files. Is there a way of doing this for people who are unable to understand even the most basic coding instructions?

Anonymous said...

What tha hell are y'all talking about!