Source code


MEMU is written in largely portable C. A few bits are UNIX or Windows specific, particularly around the windows used to display graphics in, and fielding the keystroke events received in them. To that end, there are two seperate platform specific implementations of the windowing code, and in a few places in the code, there are a few #ifdef statements.

If you don't want joystick support, you can #define NO_JOY, thus removing the dependency on /usr/include/linux/joystick.h on Linux, or DirectInput headers and libraries from the DirectX SDK on Windows.

If you don't want DART support, you can #define NO_DART. This option is used on Windows, as the current implementation works best when used with UNIX style named pipes.

If you don't want the 80 column screen to be emulated in text mode, then you can #define NO_TH and not link with th.a or th.lib. This can help when building MEMU on Raspberry Pi, by removing the dependency on TH, and thus the dependency on ncurses.

There are various hooks in the source allowing the MEMU code to be used as a part of Bill Brendlings MEMU-Pi project.

On MacOSX, I currently use Yosemite with XCode (clang based) and XQuartz (which doesn't seem to run very fast). This is why I describe the MacOSX version as "beta quality".



If you want to build MEMU, you need either gcc or MS Visual Studio 2013 or later. With a bit of tweaking of the UNIX makefile, other compilers and XWindows directory locations can be accomodated.

On Kubuntu, I am advised that you need to

# apt-get install build-essentials
# apt-get install libncurses5-dev


On Linux you'll need the PortAudio package installed, as MEMU uses this for its sound support. As I use Fedora, I used dnf -y portaudio portaudio-devel to get this. On your Linux distro this may differ. On Kubuntu, I am advised that you need to

# apt-get install libportaudio2
# ldconfig

Also, you may need to amend the makefile to be more like the MacOSX case (ie: explicitly specify paths to the PortAudio headers and libraries.

On Windows you'll need to download the PortAudio source and build it. This can be quite tortuous, as you need the Direct Sound headers and libraries from within the Microsoft Direct/X SDK, and optionally, the ASIO library from Steinberg Media Technologies GmbH. At least the process of building PortAudio for Windows is well documented on a page on the PortAudio wiki. I built two versions of the PortAudio libraries, one with ASIO support, one without, and they both seem to work fine on my system. I only include the non-ASIO variant of portaudio_x86.dll with the MEMU distribution because the ASIO variant is subject to the ASIO license.

Dependant modules

You also need to build the DIRT and TH modules before building MEMU. DIRT is a library of Directory Traversal code, which MEMU uses in its CP/M emulation layer when enumerating files in a directory. TH is a library of Terminal Handling code, which MEMU can use in its emulation of the 80 column card and driver (if you use the -mon-th option).

To build DIRT and TH :-

  1. Change into their directory
  2. Copy the files from the unix or win32 subdirectory to the current directory
  3. Run make or nmake


To build MEMU :-

  1. Change into its directory
  2. Copy the files from the unix or win32 subdirectory to the current directory
  3. Edit the makefile, so that the variables DIRT and TH reflect the directories where these modules are.
  4. If running on a big-endian architecture, you'll need to change the -DLSB_FIRST compiler flag to -DMSB_FIRST.
  5. On Windows, edit the makefile so that the PORTAUDIO variable reflects where PortAudio is.
  6. Run make or nmake


The source code is "folded", and was written using AE, also found at the same site that you found MEMU. If editing using a normal "flat" editor, you'll see strange "fold-crease" comments in the code.