Skip to content

Instantly share code, notes, and snippets.

@Postrediori
Last active January 31, 2024 12:30
Show Gist options
  • Save Postrediori/bf5f60a1e109426356e58837ffca3436 to your computer and use it in GitHub Desktop.
Save Postrediori/bf5f60a1e109426356e58837ffca3436 to your computer and use it in GitHub Desktop.
Build higan emulator (https://higan-emu.github.io) from a source code on a RedHat-based system (including Fedora and CentOS)

See also: Build ares emulator on Fedora – a newer emulator based on Higan/bsnes source code.

Introduction

This document describes hot to build higan emulator from a source code on a RedHat-based system (including Fedora and CentOS).

higan is an emulator for a number of classic video-game consoles of the 1980s and 1990s, allowing you to play classic games on a modern general-purpose computer.

Installing pre-requisites for building

You will also need GCC 4.9 or higher, including the C and C++ compiler, GNU Make, and development files (headers, etc.) for the following libraries:

  • GTK 3.x
  • PulseAudio
  • Mesa
  • gtksourceview 3.x
  • Cairo
  • SDL 1.2
  • libXv
  • libAO
  • OpenAL
  • udev

On a RedHat-derived Linux distribution (including CentOS and Fedora), you can install everything you need with a command like:

sudo dnf install -y \
    gcc \
    gcc-c++ \
    gtk3-devel \
    pulseaudio-libs-devel \
    alsa-lib-devel \
    gtksourceview3-devel \
    SDL-devel \
    SDL2-devel \
    libXv-devel \
    libao-devel \
    freealut-devel \
    systemd-devel

Acquiring the source code

git clone --recursive https://github.com/higan-emu/higan.git higan-src

Compiling from source on Linux

Once you have all the dependencies installed, you may build and install higan.

Note: Run these commands as yourself, do not run them as root (no sudo, no su, etc.), because higan does not support being installed system-wide.

  • Put the higan source code in some convenient location, like ~/higan-src
  • Open a terminal window
  • Type cd ~/higan-src (or wherever you put the higan source) and press Enter
  • Type make -C higan-ui and press Enter to build the main higan executable
  • Type make -C icarus and press Enter to build the icarus import tool
cd higan-src
make -j4 -C higan-ui
make -j4 -C icarus

Cleaning object files

To start compilation from the beginning, run the following prior to compiling:

cd higan-src
make -C higan-ui clean
make -C icarus clean

Installing a compiled build

Assuming higan is compiled as described in the previous section:

  • Open a terminal window
  • Type cd ~/higan-src (or wherever you put the higan source) and press Enter
  • Type make -C higan-ui install and press Enter to install higan and its supporting files
  • Type make -C icarus install and press Enter to install icarus and its game database
cd higan-src
make -C higan-ui install
make -C icarus install

This installs higan and its associated data files into the ~/.local directory hierarchy.

Uninstalling a compiled build

To uninstall higan, as installed by the above instructions:

  • Open a terminal window
  • Type cd ~/higan-src (or wherever you put the higan source) and press Enter
  • Type make -C higan-ui uninstall and press Enter
  • Type make -C icarus uninstall and press Enter
cd higan-src
make -C higan-ui uninstall
make -C icarus uninstall

To remove higan’s configuration, delete the following directories if they exist:

~/.config/higan/
~/.config/hiro/
~/.local/share/higan/
~/.local/share/hiro/

To remove the games imported into higan’s library (including in-game saves and save-states), delete the directory ~/Emulation.

Compiling bundle for running on another system

The following commands create a bundle for running higan on another RedHat-based system.

Build the higan and icarus executables with flags build=performance local=false

cd higan-src
make -j4 -C higan-ui build=performance local=false
make -j4 -C icarus

Create directory higan-bundle and copy binaries with dependencies there

mkdir higan-bundle
cp -a higan-ui/out/higan higan-bundle/higan
cp -a higan/System higan-bundle
cp -a icarus/out/icarus higan-bundle/icarus
cp -a icarus/Database higan-bundle
cp -a icarus/Firmware higan-bundle
cp -a extras/* higan-bundle

Copy higan-bundle directory to another Fedora system and install dependencies:

sudo dnf install -y \
    gtksourceview3 \
    openal-soft
@Keithenotfricker
Copy link

That fixed the whole issue, higan was compiled succesfully running that command! Thanks a lot for answering! ngl I wasn't even expecting an answer to begin with. Hope you have a great day/evening/night!

@Postrediori
Copy link
Author

@Keithenotfricker Good that it worked, I updated the steps with that info.

@psebastian21
Copy link

Hello, getting this all over the place on fedora 38 x86_64:

/nall/arithmetic/natural.hpp:239:23: error: ‘runtime_error’ is not a member of ‘std’ 239 | if(!rhs) throw std::runtime_error("division by zero");

seems like a source code error to me, what do you think?

@Postrediori
Copy link
Author

Postrediori commented Jun 7, 2023

Hi there @psebastian21 ,
It seems like the code base is no longer compatible with current mainline GCC 13. This was fixed in ares (commit: ares-emulator/ares@6a78983) but not in higan.
Maybe I'll create PR for that in the higan repository, but who knows if it would be merged.

@Postrediori
Copy link
Author

Postrediori commented Jun 8, 2023

@psebastian21 Try downloading&building it again, the fix is now merged into the mainline. Also note that dependencies switched from GTK 2 to GTK 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment