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.

Tuesday, October 27, 2015

So You Want to Develop Web Apps?

- "I want to develop web applications. Where should I start?"
First learn HTML

- "Ok, I got that, but my web pages look very bland. What am I missing?"
Now you need to learn CSS.

- "Now my pages look great, but they don't do anything."
You need to learn Javascript to be able to program your web page. Make sure to read Douglas Crawford's book to learn how to avoid the many pitfalls of Javascript.

- "Now I know HTML, CSS, and Javascript. What else do I need?"
To make applications you need server-side code. You could learn Java, C#, Python, Ruby, PHP or a host of other languages. I would recommend Python.

- "Now how do I wire up my Python code to my web page."
Oh, you need a framework to do that. Again, there are many to pick from. Try Django.

- "Ok, I have Django down. Am I ready?"
You will need to learn databases to be able to persist data between visits to your page. Mysql is a free and powerful database. Don't forget to understand how to normalize your database into third-normal form, but also how and when to denormalize your database for performance.

- "Now that I understand databases, how do I tie it into my application?"
Django has a powerful ORM that will map your Python objects to database tables. Oh, you did learn Object Oriented Programming when learning Python, right?

- "I have learned object-oriented programming, and Django's ORM. I'm ready to build web applications now, right."
Well, you want to do it right I presume. Now you need to learn how to do asset management, how to write RESTful APIs, and how to use virtualenv to manage your Python libraries.

- "Fine, I can manager all of my application resources effectively and write APIs. Am I ready now?"
All that code needs to run somewhere. You can't serve it up from your development machine using the dev tools. You need to learn Linux. I prefer Ubuntu. You will need to learn how to install software with apt, write bash scripts, and generally get around using the command line. This will include using a terminal-based text editor like vim.
You will need a production-ready web server software like nginx. You will need to know how to install, configure, and maintain it.

- "Certainly I'm ready now."
You need to learn jQuery to make your Javascript easier. Also, since you started HTML5 has come out, which contains addition to not only HTML, but also to CSS and Javascript. ECMA Script 6 is also on the horizon. You will want to read up on that, and use something like Babel to convert it for you. You also need to learn node and NPM to help better maintain your Javascript libraries. You need to know React so that your front-end code doesn't require a complete page reload after every click, and also so that you don't need a bunch of complicated listeners to refresh every element whenever something happens. Web sockets will allow you to push changes from the server to your web page without having to make expensive polls every few seconds.

- "Okay, okay, okay. I've got all of that down. I'm ready to start building."
You can't just write code. You need something to maintain that code. You now need to learn git so that you can keep versions of your code and share it with anyone else working with you. It's important that you can fork, commit, branch, stash, and rebase.

- "Okay. I'm ready for whatever insanity you still have to throw at me."
One last thing. Since you don't have a computer science degree or any professional experience, you now have to convince someone to hire you based only on your interviewing skills. You do know how to sell yourself, right.

Friday, October 2, 2015

Installing Kill Bill on Ubuntu 14.04 with Tomcat 7.

I'm not a Java guy, and the guides out there seem to assume knowledge of deploying Java apps, so this took me a some time to get right, so I'm going to document the steps I took here.

sudo apt-get install mysql-server mysql-client default-jdk tomcat7 tomcat7-common tomcat7-admin libmysql-java

Kill Bill uses odd minor numbers for developing new features and even minor numbers for production releases. The download page Hold off downloading anything until the instructions call for it.

First we need to initialize the mysql database. We need a user and database for the killbill application. The following assumes that the root mysql user's password is foobar, that the database will be named killbill, and that the username and password for the application will be killbill:killbill. All of these are fine defaults with the exception of the passwords. Change as needed.

mysql -u root -pfoobar
mysql> create database killbill;
mysql> create user 'killbill'@'localhost' identified by 'killbill';
mysql> grant all on killbill.* to 'killbill'@'localhost';
mysql> exit

Now we need to initialize the database with the tables. At the download page, download the corresponding ddl.sql for your version of Kill Bill.

mysql -u root -pfoobar --database=killbill < ddl.sql

Now that our database is setup we can configure Tomcat. First we need to setup credentials for the admin page. As root, open /etc/tomcat7/tomcat-users.xml and replace the contents to look like this, replacing the username and password fields with what you want to use.

  <role rolename="manager-gui"/>
  <role rolename="tomcat"/>
  <user password="tomcat" roles="tomcat,manager-gui" username="tomcat"/>

Next, we need to set the maximum upload to a sane value that will be sufficient for uploading the WAR file. As root, open up /usr/share/tomcat7-admin/manager/WEB-INF/web.xml and find the key max-file-size. Set the lines as follows.


Finally we need to configure Tomcat to connect to the killbill database. As root, open up /etc/tomcat7/ and append the following to the end of the file, changing any values as appropriate for your setup.

# Kill Bill properties

Now that everything is configured we need to restart tomcat.

sudo service tomcat7 restart

On your local machine download the WAR file from the download page and save it somewhere so we can upload it to the server in the next step.

On port 8080 of your server running tomcat browse to /manager/html/ In the section labeled "WAR file to deploy" click the "Choose File" button, select the WAR file you downloaded and then click the "Deploy" button.

When the upload is complete the page will refresh and you should see it listed in the Applications section. Finally, click the Start button next to the killbill application and you should be in business.

If the application will not start go over this guide to make sure you followed all the steps correctly. You can also look at the log files in /var/log/tomcat7/ to troubleshoot.

As of Ubuntu 15.04 the tomcat8 and openjdk-8 packages are available to install. Both of these packages should be more performant, but it is up to you to try them out if you so desire.