Monday, December 14, 2015

Compiling Mame on Ubuntu 14.04 Trusty Tahr

This is an update from How to compile mame in Ubuntu 10.04 Lucid Lynx. Using the following instructions you should be able to compile Mame on Ubuntu 14.04 Trusty Tahr, though it should also work in most any other version of Ubuntu too.
  1. Install dependencies.
    sudo apt-get install git build-essential libgtk2.0-dev libgnome2-dev libsdl1.2-dev libsdl-ttf2.0-dev libsdl2-ttf-dev libqt4-*
  2. The version of gcc and g++ that comes with Ubuntu 14.04 will not compile the latest Mame code. Fortunately, there is a PPA to get a newer version. This step is not needed on versions of Ubuntu beyond 14.04 as they come with versions 4.9 or above of gcc and g++.
    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt-get update
    sudo apt-get install gcc-4.9 g++-4.9
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50
  3. Get the latest code from github.
    git clone
  4. Finally, lets get to building it. This will take a very long time, perhaps even hours. This may be a good time to take a nap, watch some Star Trek, or visit the park with the family you've been neglecting trying to get all of this to work.
    cd mame
  5. On 32-bit systems the resulting binary file will be called mame and on 64-bit systems it will be mame64. We want to make this binary executable by everyone on the system so we need to put it in the correct directly.
    sudo cp mame64 /usr/local/bin/mame
    sudo chown root:root /usr/local/bin/mame
    sudo chmod 755 /usr/local/bin/mame
  6. Mame has a hierarchy of places it will look for a config file. The easiest, and best route is to place it in our home folder.
    mkdir ~/.mame
    cd ~/.mame
    mame -createconfig
  7. Let's setup a rom folder and get some roms.
    mkdir roms
    cd roms
    wget --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070725 Firefox/"
  8. Now that we have legally obtained an arcade ROM, let's play it!
    mame sidetrac
There is a reasonably good chance that some unnecessary libraries are installed via this guide, and if someone knows of a library that can be safely omitted, please let ma know below in the comments.

There are several points of possible confusion when trying to run an arcade rom.

  • mame -showusage will output what we would normally expect with a --help switch.
  • A rom must be in the proper rom folder as defined in mame ini file. If you have the rom in the current folder and run mame, mame will not look at the file in the present directory and try to load it. If is in the rom directory, and you run mame dkong then it will be able to run the rom. Mame is sensitive to the name of the zip file. If you rename the file then Mame will not know where to find the rom and will give you an error.
  • Unlike most emulators, mame has specific code to support each rom. It doesn't just arbitrarily run rom code. The format of many roms has evolved over time. Many roms found on the Internet are in an old format and are missing files that Mame needs to accurately emulate the game. Trying to execute these roms will result in an error about missing files. Since Mame developers actively discourage the use of Mame for the purpose of piracy they will be very unsympathetic to your plight and will not help you.
  • Some roms are a "clone" over another rom and require its parent rom to run. Which roms these are, and what parent rom they need is not well documented (that I know of) and will looks just like an old rom that is missing files required by the latest Mame.
  • Just running the Mame binary will provide you with an interface that will list all available roms in your collection. It is not necessary to specify the rom to load when executing Mame.
  • I am not very sympathetic to copyright owners that do not provide meaningful ways to legally obtain their copyrighted materials. I would very much like a way to purchase roms that will play on Mame from the companies that own the IP. However, I will not provide you with any help or resources on obtaining roms illegally. You are on your own.
More information on Mame roms can be found at

Once you know what libraries to install, compiling Mame from source is quite easy in Ubuntu. Drop me a line in the comments if this is helpful, or if you run into any problems or have any suggestions.