bsnes Compilation Guide

If you want to compile bsnes from source code, this guide is for you. With the exception of Linux, this can be tricky. You should be familiar with the command-line, and preferrably familiar with software compilation.

This is also the only way to obtain OS X and Linux binaries for now, unfortunately. Windows users should stick to the official build, as it is fully profiled and optimized, with all add-on drivers already included.

OS X users, note that my version is very different from Richard Bannister's port. You should use mine if you seek the absolute latest releases with all features, including the debugger, exposed. If you prefer simplicity and full Apple HIG compliance, you should stick with his DMG releases.

Windows

First, install the latest version of TDM/GCC.

Next, install the DirectX 9.0c SDK.

Next, obtain the latest version of glext.h.

Next, install the latest version of Qt for Windows.

Now it's time to update the painfully out-of-date headers that ship with MinGW. First, go to the DirectX SDK install directory, and go into the include folder. Copy every file here. Now go to the MinGW install directory, and go into its include folder. Paste the files here. It will warn you that it will be overwriting files. Choose to overwrite them all.

Now copy the glext.h file from earlier, and go to the MinGW install directory, then into the include folder, and then into the GL folder, and paste the file here. Overwrite the existing one.

Now MinGW and Qt need to be set up so that they can be used from the command line. Hold the Windows key down and press the Pause/Break key. This will bring up your system properties window. On Vista or later, you will need to choose "Advanced System Settings" or similar from the left. Now choose "Advanced", and click on the button for "Environment Variables". On the bottom list, look for PATH, and click to edit it. Add the paths to the bin directories for both MinGW and Qt to the very beginning. For instance, it may look something like this:

c:\mingw\bin;c:\qt\4.6.0\bin;

Adjust as needed. Make sure not to remove any of the existing text when adding the new paths. Once done, you should be able to run "gcc -v" from the command line to see the GCC version.

Now, go to the Qt install directory, and edit mkspecs/win32-g++/qmake.conf. Look for QMAKE_CFLAGS_RELEASE = -O2 and set it to:

QMAKE_CFLAGS_RELEASE = -Os -fomit-frame-pointer

That will make significantly smaller Qt runtime binaries. Now go to the command prompt, and cd to the Qt installation folder, which should be similar to "cd c:\qt\4.6.0".

Now it's time to configure Qt. Use the following command for that:

configure -release -opensource -shared -no-exceptions -no-accessibility
-no-stl -no-qt3support -no-rtti -no-openssl -no-dbus -no-phonon
-no-phonon-backend -no-multimedia -no-webkit -no-script -no-scripttools
-no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde

I had to split it into multiple lines to fit on this page, make sure that when you paste this command in, that there are no line breaks.

After a few minutes, you'll be ready to build. Use the following command:

mingw32-make sub-src

After a long time, you'll be finished with the build environment. Now to build bsnes ...

Download the latest bsnes source code, and go into the src/ folder. Run cc.bat and wait a minute or so. The executable will now be in the folder above src/.

To build snesreader, snesfilter and supergameboy; download their source archives, extract them, run their cc.bat files, and copy the DLL outputs into the bsnes binary folder.

OS X

First, install the latest version of Xcode.

Next, install the latest version of Qt for OS X. Make sure to grab the Cocoa release version, and not the Carbon or debug versions.

Next, install the latest version of Macports.

You will need GCC 4.4 or later for C++0x support. From the terminal, run the following command:

sudo port install gcc44

This will take several hours, as it builds GCC 4.4 from source, rather than simply downloading and installing a binary package in two minutes. I know, I'm as amazed as you are.

Finally, download the bsnes source code, and from a terminal run the following commands:

cd src/
make

bsnes.app will appear in the folder above src/. It can now be placed inside the Applications folder if desired.

Next, snesreader, snesfilter and supergameboy can be added. Simply extract each of their source code archives, and run the following commands for each:

make
sudo make install

Linux

First, install the necessary build tools and libraries by running the following commands the terminal:

sudo apt-get install build-essential libqt4-dev libsdl1.2-dev
sudo apt-get install libpulse-dev libopenal-dev libao-dev libxv-dev

Next, extract the bsnes source code, and run the following commands:

cd src/
make
sudo make install

bsnes should now show up under your games menu. It can also be run via "bsnes" on the terminal.

Next, snesreader, snesfilter and supergameboy can be added. Simply extract each of their source code archives, and run the following commands for each:

make
sudo make install