8 Compiling
bearoso edited this page 2023-03-09 16:58:43 -06:00

Windows

Various software and tools are required to compile Snes9x on Windows:

NOTE: Unicode support requires a special zlib build - see the end of the zlib entry

  • The current official binary is compiled with Visual Studio 2017, you'll have to create your own project file for earlier MSVC versions. VS2017 will automatically ask to install the correct Windows SDK Version (7.1A)

  • A recent DirectX SDK: https://www.microsoft.com/en-us/download/details.aspx?id=6812

  • The following modules can all be downloaded automatically by using: git submodule update --init in the cloned Snes9x git directory, or by using git GUI tools to do the same. This is the recommended method of installing these dependencies.

    • DirectXMath. The source files should reside in win32/DirectXMath This is no longer used with version 1.62.

    • zlib (optional, ZLIB define, enabled by default) - the default solution includes a zlib project that builds appropriately (force includes _tfwopen.h for unicode support in s9x). The zlib source files should reside in win32/zlib/src

    • libpng (optional, HAVE_LIBPNG define, enabled by default) - the default solution includes a libpng project that builds appropriately. The libpng source files should reside in win32/libpng/src

    • glslang and SPIRV-Cross (optional, USE_SLANG define, enabled by default) These are needed to build support for .slang shaders. The default solution includes a series of projects encompassing glslang that build appropriately. The glslang source files should reside in external/glslang or shaders/glslang on 1.61 and earlier. The SPIRV-Cross source files should be placed in external/SPIRV-Cross or shaders/SPIRV-Cross on 1.61 and earlier.

      If wish to compile without USE_SLANG, you must remove the files named spirv_*.cpp from the Visual Studio project's Shaders group.

  • To compile Snes9x: Start up VS2017. Load the Snes9x solution. Select the desired configuration and build. The Release configuration may build significantly slower than Debug. Then you can run it.

GTK

Requirements:

  • gtkmm-3.22 or greater and all dependencies
  • SDL 2.0
  • X11, even if only using Wayland
  • libepoxy
  • CMake (meson for older versions)

Optional:

  • PulseAudio
  • ALSA
  • OSS
  • PortAudio
  • Wayland
  • libpng
  • minizip
  • zlib

Check out glslang and SPIRV-Cross: (Optional for slang shader support)

glslang and SPIRV-Cross are submodules located in the main source directory at shaders/glslang and shaders/SPIRV-Cross. If you are using a git clone, to get all the necessary projects you can simply run:

snes9x$ git submodule update --init --recursive

If you are using a tarball, but have git installed, you can run:

snes9x$ git init && git submodule update --init --recursive

Otherwise, you will need to place the glslang source files in shaders/glslang and the SPIRV-Cross source files in the shaders/SPIRV-Cross directory manually.

  1. Use the appropriate configure tool to generate build files. Only this first step is different. The rest of the build process will use the "ninja" program.

Configuring with CMake:

Newer versions have replaced meson with CMake. Change to the gtk directory and run cmake.

snes9x/gtk$ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -S . -B build

Building with meson: for older versions that have a meson.build file

Change to the gtk directory and run meson:

snes9x/gtk$ meson build --prefix=/usr --buildtype=release --strip

A list of options can be found in meson_options.txt. Most will be autodetected.

  1. Build with ninja:
snes9x/gtk$ cd build
snes9x/gtk/build$ ninja
  1. Install:
snes9x/gtk/build$ sudo ninja install

Mac

The only tool required to build Snes9x on Mac is Xcode, which can be installed from the Mac App Store or, if you have an Apple Developer account, from https://developer.apple.com/download/release/

Once Xcode is installed, follow these steps to build Snes9x.

  1. Clone the snes9x git repository.
  2. Clone the submodules by running git submodule update --init --recursive inside the repo.
  3. Open the macosx/snes9x.xcodeproj file.
  4. Click the build and run (▶︎) button at the top-left of the window or choose Run from the Product menu.