Emulation on Mac

Emulating classic video game consoles on Mac OS X

Tag Archives: SDL

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.