Emulation on Mac

Emulating classic video game consoles on Mac OS X

Tag Archives: open source

Building Fceux from Source on Mac OS X Yosemite (10.10)

Fceux is a cross-platform, open-source NES emulator. There are other options for NES emulation on Mac OS X, but FCEUX offers tools for debugging, rom-hacking, map making, Tool-assisted movies, and Lua scripting. Basically it’s the “hacker’s choice” of NES emulator. Unfortunately, some of those hacking features are exclusive to the Windows version currently (boooo), so maybe the project needs some help from Mac users. Or, you might just want to have a version of Fceux that is not 18 months out of date, because the project hasn’t released a binary since 2013 despite the fact that bugs continue to get fixed. Let’s show how to build their source code on Mac OS X.

First, we need to install all of the dependencies. I assume you already have XCode installed with the command-line tools, and that you’re using MacPorts to install open-source packages. Note the versions of things here. At the time of this writing, you don’t want the latest Lua; Fceux will fail to build. April 2016 edit: I added pkg-config to this list of dependencies.

 $ sudo port install scons
 $ sudo port install libsdl2
 $ sudo port install gtk2
 $ sudo port install lua51
 $ sudo port install pkg-config

Next, get the latest code from their repository:

 $ svn checkout svn://svn.code.sf.net/p/fceultra/code/fceu/trunk fceultra-code
 $ cd fceultra-code

Now, a small change to their Sconstruct file is necessary, to fix an issue with how they’re setting up the build environment. On the line immediately after the “env” variable is set, add the following:

env.Append(ENV = {'PATH' : os.environ['PATH']})

Finally, we can build and run the emulator, but we have to add some more paths to the command line in order for the build process to find all the stuff we installed with MacPorts. If you prefer Brew as your package manager, your paths here will be different (CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib scons)

 $ CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib scons
 $ ./src/fceux

Optionally, we can build and run the server component, for network play.

 $ cd fceux-server/
 $ make all
 $ ./fceux-net-server

Network play allows two (or more?) instances of Fceux to share game-state by continuously syncing, over the network.


PSP emulation using PPSSPP on Mac OS X 10.10.1 (with MacPorts instead of HomeBrew)

This fantastic open-source emulator of PSP runs on basically everything, but it’s a little harder to get working on Mac OS X. At least the main site now hosts compiled binaries for OS X, which is an improvement from not too long ago when the only binaries available were on a third party build site. We no longer have to run the Windows version under a Wine wrapper. Things have come a long way.

But you still have to download and install a dependency first: the SDL runtime (Simple DirectMedia Layer), because the developer follows the Linux philosophy of no statically linked libraries (“make it the user’s problem to try to recreate the exact dynamic library setup that the developer used through trial-and-error!”).

There are directions for installing SDL if you use Homebrew as your package manager. I don’t, though. I use MacPorts. The two are mutually exclusive, and would interfere with each other if you were to try using them together. So this post is about how to get PPSSPP working if you are a MacPorts user.

First, I assume you’ve gotten XCode from the App Store, opened it to download the XCode command line tools, and then installed MacPorts. If you run the following commands, you can correctly set up the LibSDL dependency.

sudo port install libsdl
sudo ln /opt/local/lib/libSDL-1.2.0.dylib /usr/local/lib/libSDL-1.2.0.dylib
sudo ln /opt/local/lib/libSDL.a /usr/local/lib/libSDL.a
sudo ln /opt/local/lib/libSDL.dylib /usr/local/lib/libSDL.dylib
sudo ln /opt/local/lib/libSDLmain.a /usr/local/lib/libSDLmain.a

Do you get an OS X CrashWrangler bug report dialog, saying it crashed because it couldn’t find “/usr/local/lib/libSDL-1.2.0.dylib”? You might have not created the aliases correctly in /usr/local/lib. Do you get a “Segmentation fault: 11” with a thread that crashes in the pthread library, while the main thread is trying to call SDL_SetVideoMode() from its own SDL_Main()? Then you probably aliased libSDL-1.2.0.dylib correctly, but messed up the others. I did that once. Woops.

Why is PPSSPP not statically linked to its dependencies? Why does it not save user data in the right place (it will save your games in a hidden folder, very non-Mac like: you’ll have to open up “/Users/your_name/.config/PPSSPP/” to find your save files, the ini files where you enter per-game cheats, etc.)?

Building from source:

If you would rather build PPSSPP from source yourself, try these steps (using MacPorts):

sudo port install cmake    # because the build process needs cmake
git clone https://github.com/hrydgard/ppsspp.git ppsspp_dev
cd ppsspp_dev
git submodule update –init   # their wiki instructed to do this (?)
git submodule update             # seemed to do nothing (?)
mkdir build-osx-fat
cd build-osx-fat
cmake /path/to/ppsspp_dev

If you did want to put MacPorts aside and try HomeBrew just for a minute, and only to install SDL:

sudo rm /usr/local/lib/libSDL*  # delete the hard links to the MacPort version of SDL
ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)”   #ugh, it chowns /usr/local to non-root! stupid!
brew doctor   # sure enough, it warns me that I will have a ton of problems because I use MacPorts
sudo mv /opt/local ~/Desktop/macports     # move all my MacPorts-installed packages somewhere safe, temporarily
export PATH=/usr/local/sbin:$PATH          # temporarily add this to the PATH because HomeBrew wanted me to.
brew install sdl

And then to get rid of HomeBrew again and go back to using MacPorts, you would do this:

brew remove sdl
cd `brew –prefix`    # puts me in /usr/local
rm -rf Cellar
brew prune
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
sudo mv ~/Desktop/macports /opt/local   # restore MacPorts
sudo chown -R root:wheel /usr/local     # undo the security damage to the permissions that HomeBrew’s installer did.