# Compiling MESS

(This document is based on "How to compile MAME (Win32)". Since the procedure for compiling MAME and MESS are virtually identical, these two documents are virtually identical)

Compiling means rebuilding the actual executable program from its source code. MESS is almost fully written in C, with some assembler hacks in speed-critical places. The Win32 version of MESS is compiled with MinGW, which is the minimalist Win32 port of a C compiler called GCC and its libraries.

This particular how-to is written for MESS 0.80, but with a bit of luck you can compile other versions with the help of this page. This how-to tells how to compile the Win32 version of MESS, which includes both the command line and GUI versions.

The MinGW development environment will be installed to C:\MINGW and MESS sources will be placed into C:\MINGW\MESS. Before beginning, you should make sure that you do not have the directories c:\mingw\ and c:\download\ yet. If you do have them, rename them to another name or simply delete them (if you are sure that there aren't any important files in there).

Remember, when you type commands into the command prompt, you should avoid making typos ;-) In this how-to, filenames and other static text are marked with the color brown and command lines or other information that you need to type in are marked with the color green .

## 1. Get Unzip

First of all, most files that are transferred over the Internet are compressed, to minimize download times and bandwidth costs. You might already have a Windows-based uncompressing utility, but since compiling MESS is done in a command prompt, a different kind of utility is necessary. Download the following file into the directory c:\windows\command\ so that the utility is accessible from any directory.

File name | File size | Description
unzip.exe | 140kB | This is the Info-ZIP uncompressing utility called UnZip/NT v5.41.

## 2. Get Win32 ports GNU Tar and GNU Unzip

These utilities are needed by step 4 to properly patch the MinGW toolchain. Again, you may already have an archiver capable of extracting .tar.gz files.

File name | File size | Description
UnxUtils.zip | 2911kB | Native Win32 ports of some GNU utilities.

## 3. Get MinGW

Then you need the MinGW files. Make a new directory, for example c:\download\ and download the following files into that directory. Note that there may be newer versions of these files, but MESS is not verified to compile with any other versions of the following files.

File name | File size | Description
MinGW-2.0.0-3.exe | 12525 kB | MinGW 2.0.0 compile environment for use in Windows.
mingw-over.zip | 549 kB | Other files needed to compile MESS in the MinGW compile environment. Uncompress this over the MinGW directory and add c:\mingw\bin to your PATH. Compile the Win32 version by typing make.
gcc-3.2.2-20030208-1.tar.gz | 7148 kB | GCC 3.2.2, required for MESS 0.80. Uncompress this over the MinGW directory.
dx70_mgw.zip | 240 kB | DirectX 7.0 headers, required for MESS 0.80. Uncompress this over the MinGW directory.

## 4. Uncompress MinGW

Next we will uncompress the MinGW files and set up some environment variables so that MinGW is functional. First run the MinGW installer, which will install a fresh MinGW installation. Now you need to add a few associated files to the MiNGW installation. Open up a command prompt. You can find it either from under Start Menu --> Programs, or you can simply select Run and type command.com into the dialog box. When you have it open, type cd \Program Files\MinGW and hit enter to change to the correct directory. After that, type

- gunzip c:\download\gcc-3.2.2-20030208-1.tar.gz
- tar -xvf gcc-3.2.2-20030208-1.tar
- unzip c:\download\dx70_mgw.zip -d c:\

If you do not see the message "1 archive was successfully processed.", re-download the archives. If you get a "Bad commmand or file name", verify once again that you have unzip.exe in c:\windows\command\

## 5. Set up MinGW

Next we will have to set up the environment variables. To make the changes permanent, we will have to edit AUTOEXEC.BAT, which is a file that always gets run before Windows starts up. Type edit \autoexec.bat and hit enter. There might be a lot of things in there, so do not touch anything else than what you are told to.

Find the line which says something like PATH C:\WIN98;C:\WIN98\COMMAND (there might be some other directories defined after these two). Add ;C:\MINGW\BIN to the end of that line, so that it will look like PATH C:\WIN98;C:\WIN98\COMMAND;C:\MINGW\BIN (again, there might be something extra in there, leave them as they are). Take note that if you have added C:\DJGPP\BIN into that line, you should remove it. Now you can save the file (ALT-F then S) and quit (ALT-F then X ) (These might differ depending on your language version of Windows). Then you will need to reboot your computer, to make the changes effective.

With systems that don't use startup files (such as Windows NT, 2000 or XP), you can instead type edit c:\mingw\mingw.bat and write SET PATH=%PATH%;c:\mingw\bin into it. You'll have to run this file (simply type c:\mingw\mingw to run it) before being able to use MinGW.

## 6. Compile MESS

Now you can compile MESS. The MESS source is distributed as a source override on the MAME source. Therefore you will need to download both the MAME and MESS source ZIPs into c:\download\

File name | File size | Description
mame080s.zip | 9208 kB | This is the source archive of MAME 0.80.
mess080s.zip | 2717 kB | This is the source archive of MESS 0.80.

Go to the download directory by typing cd \download and uncompress the MAME and MESS sources by typing the following commands

- unzip mame080s.zip
- unzip mame.zip -d c:\mingw\mess\
- unzip mess080s.zip -d c:\mingw\mess\ .

Then you can compile MESS. Type make -f makefile.mes and hit enter. This will finally compile MESS itself. If you want to compile the CPU optimized versions, type make -f makefile.mes I686=1 or make -f makefile.mes K6=1 instead of just make -f makefile.mes . It will take a lot of time, ranging from 15 minutes to an hour depending on your CPU speed, so go get yourself something to drink.

When the compilation is done, you can type dir. You should see a brand new MESS.EXE in there.

You also need to make the INI file, by typing mess -cc (an abbreviation of -createconfig).

Congratulations, you did it!

## 7. A new MESS appeared

To successfully compile a new version of MESS, you should NOT uncompress a new set of sources over an old version of MESS. Instead, rename the MESS directory to another name or simply delete it totally (if you are sure that nothing important is there), and then uncompress the new set of sources to an empty directory.

## 8. Then what..

Of course, the biggest advantage of building your own binary is the possibility to tinker around with the source files. For example, to try out drivers which are not fully working yet, take a look at the file mess/system.c with a normal text editor (like EDIT). The disabled drivers are marked with the text TESTDRIVER. Simply remove the TEST part from a driver you want to test, save the file and type make -f makefile.mes again. Remember, the license forbids you from redistributing binaries that contain systems which are disabled in the official versions. Naturally, there should not be any reasons to redistribute such binaries since this page makes it easy for everybody to build their own binaries.

You might notice that the executables created by the build are much larger than the ones released by the MESS team. This is because the MESS releases are archived with UPX to make them smaller.

## 9. Debug modes

To include the debugger functionality in your MESS executable, edit makefile.mes. Near the top you will see a text like "uncomment next line to include the debugger". Remove the # character from the next line, so that it only has DEBUG = 1 in that particular line. Save the file, type make -f makefile.mes clean and then make -f makefile.mes. To actually use the debugger, edit MESS.INI and find the line that says debug = no. Change it to debug = yes and save the file. In MESS, hit tilde ( ~ ) or key to the left of the key 1 to enter the debugger.