Preparing the build environment

This should be required only once. We will use a GNU environment in Windows for building. You can also try Visual Studio, but since I do not have it, I cannot give further help here. See https://docs.mamedev.org/initialsetup/compilingmame.html for further information.

Most of the following information can be found on the MAME Documentation Wiki: Compiling MAME in Windows

1. Download MSYS2 and install it

For Windows x64, please download the installer from the MSYS2 website. This is free software.

Start the executable package by double-click. The installer allows you to choose an installation directory; if you do not pick the default (C:\msys64), make a note of it and replace the default path whenever it appears in the following setup. You can run MSYS2 Setup directly from the installer.

Should Windows Defender warn you about a possible security hazard, please ignore that and insist on installing (More info, Install anyway).


2. Set up MSYS2

When you run the setup, you should see something similar to the Windows command prompt, but with colored text, and a cursor blinking after a $ sign. This is the Unix-like build environment that we will use. In the following text, the commands you have to type in are shown in blue after the $ sign (which you do not type). Please make sure you type these command exactly as shown, including uppercase or lowercase. You can also copy the text and paste it behind the $ sign.

Whenever you are asked whether to proceed with the installation, enter Y or hit Return.

$ pacman -Syu

This updates the current installation.

$ pacman -S git make unzip

Installs the git, make, and unzip commands. Git is used to manage the source code, for example, allowing you to download the latest changes.

$ pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-libc++ mingw-w64-x86_64-python

Installs the compiler, libraries, and the Python interpreter.

$ cd ~
$ curl -O "https://repo.mamedev.org/x86_64/mame-essentials-1.0.6-1-x86_64.pkg.tar.xz"
$ pacman -U mame-essentials-1.0.6-1-x86_64.pkg.tar.xz
$ echo -e '\n[mame]\nInclude = /etc/pacman.d/mirrorlist.mame\nSigLevel = Never' >> /etc/pacman.conf
$ pacman -Syu
$ echo "export MINGW64=/mingw64 MINGW32=" >> .bashrc
$ exit

These are some final settings before building MAME.

Get the sources

Open the command window again (search for MINGW64 in the Start menu), type the following:

$ git clone https://github.com/mamedev/mame.git

This will download all MAME sources from Github. This may take some minutes; the source tree contains nearly 30000 files. You should see a new "mame" directory in the folder.

3. Compile MAME

If you are not already in the mame directory, enter it with the cd command.

$ cd mame
$ make -j4 SOURCES=ti/ti99_4x.cpp,ti/ti99_4p.cpp,ti/ti99_8.cpp,ti/geneve.cpp,ti/ti99_2.cpp REGENIE=1

If your PC has sufficient CPUs/cores, you can choose a higher job count (for example, -j12). You should copy this line in a file and store it in the mame folder (like "maketi"). You can then start compilation with

$ ./maketi

After compiling has finished, you should have a freshly built mame executable file. Copy this file into your MAME working directory.

4. Update MAME

$ git pull
$ make clean

With pull, your local installation is updated with all changes on Github. You should do a make clean, as shown, to avoid trouble during compiling. Then continue as described below "Compile MAME". For more information about git, please check the online documentation.


5. Forget about steps 2-4 and use my tools

I prepared some small scripts to make the preparation, building, and installation easier. You can, of course, adapt these files to your personal needs.

  • prepare: Set up MSYS2 as described above.
  • clean: Clean the build directory from a previous build
  • maketi: Build MAME.
  • mameinst: Install the newly built MAME in the target directory
  • mameprep_msys2: Fetch all ROMs and create suitable starter batch files.

This will lead you quickly through the installation and configuration process:

Download MSYS2 and install it

As described above, download the executable package and start it. Run MSYS2 from the installer as proposed at the end.

Download the prepare script

Put the prepare script in your home directory. This is the directory where you find yourself when opening MSYS2. Typically, it should be C:\msys64\home\yourname. The other three scripts are automatically retrieved.

Configure MSYS2

Run the prepare script in your home directory. Watch the output. Ideally, it should do everything mentioned above in tasks 1 and 2.

Build MAME

Run the maketi script in the mamegit subdirectory that has been created by the prepare script.

Install MAME

Run the mameinst script in the mamegit subdirectory that has been created by the prepare script. MAME will be installed in the directory C:\prg\mame.

Get all ROMs

On the first installation, the mameinst script will remind you to fetch the necessary ROMs. Go into the target installation directory (by default /c/prg/mame) and run the mameprep_msys2 script. When it is done, you will find a new folder on your desktop, containing batch files to run various TI and Geneve systems. This is done only once.


6. Troubleshooting

Sometimes, things don't work as expected, even though you swear that you did everything as you were told.

Python not found

When you start building MAME, you get the message after some time that Python was not found.

Check: Did you install Python as described above? In the command shell, enter this:

$ /mingw64/bin/python

Does this work? That is, do you get a "No such file or directory" error, or is there a Python command prompt (">>>") ? If so, exit Python with quit(). Obviously, Python is not in your path.

Check exactly what prompt you see: Is there a MINGW64 or MSYS? If you see MSYS, you opened the wrong command window. Close it and search for "MINGW64" in the Windows start menu. You might want to create a shortcut on your desktop.

Scripts are not found

Although you verified that you are in the correct directory, you see this:

$ maketi
-bash: maketi: command not found

Note that in Unix systems, the current directory is not contained in the command search path. To execute a file outside of the search path, you must provide the directory in which it is located. This is done easily by using the period as the current directory:

$ ./maketi

And now you notice that I actually wrote that in the explanation above.

We use cookies
We use cookies on our website. All of these cookies are essential for the operation of the site. They are only used on this site and not transmitted to any third party. None of them are Tracking Cookies, and they do not serve to analyze your behavior.