Building RetroArch

From Emulation General Wiki
Jump to navigation Jump to search

This page contains instructions of building RetroArch from source. Most average users should use prebuilt binaries instead.

Building on Windows[edit]

The recommended toolchain for building RetroArch on Windows is MinGW-w64 running inside the MSYS2 environment. Installers for MSYS2 can be found at Other toolchains like TDM-GCC or Visual Studio can work, but this guide will only cover MSYS2.

Preparing the environment[edit]

Once you have installed MSYS2, you will need to update it and install the toolchain packages.

Updating MSYS2[edit]

First, start the MSYS2 Shell entry that should be present in your Start Menu.

Updating your install is a multiple step operation: first you update the core, then you have to rehash the environment and finally you'll be able to properly update the rest of the system. Once you are in the MSYS2 Shell terminal, run the following commands to upgrade the core MSYS2 packages:

pacman --noconfirm -Sy
pacman --needed --noconfirm -S bash pacman pacman-mirrors msys2-runtime

Once the window closes, open the MSYS2 Shell again and type pacman --noconfirm -Su then repeat the previous operation to finish the process. Note: If you get fork errors, the second step may have failed. You should go to your msys2 install directory and run autorebase.bat manually. If that didn't solve the problem consider reinstalling msys2.

Installing the build time dependencies[edit]

The following commands will install everything you need to build RetroArch in your MSYS2 environment.

  • For 32 bit builds run:
pacman -S --noconfirm --needed git make mingw-w64-i686-toolchain mingw-w64-i686-pkg-config mingw-w64-i686-SDL2 mingw-w64-i686-libxml2 mingw-w64-i686-freetype mingw-w64-i686 python3 mingw-w64-i686-ffmpeg
  • For 64 bit builds:
pacman -S --noconfirm --needed git make mingw-w64-x86_64-toolchain mingw-w64-x86_64-pkg-config mingw-w64-x86_64-SDL2 mingw-w64-x86_64-libxml2 mingw-w64-x86_64-freetype mingw-w64-x86_64-python3 mingw-w64-x86_64-ffmpeg

For the nvidia-cg-toolkit packages, you will need to download the pkg manually from Sourceforge to your home directory for 32-bit or 64-bit, then use pacman to install them.

  • 32-bit:
pacman -U --noconfirm mingw-w64-i686-nvidia-cg-toolkit-3.1-2-any.pkg.tar.xz
  • 64-bit:
pacman -U --noconfirm mingw-w64-x86_64-nvidia-cg-toolkit-3.1-2-any.pkg.tar.xz

After installing the packages, close the MSYS2 shell and open either MinGW-w64 Win64 Shell for 64 bit builds or MinGW-w64 Win32 Shell if you want to build for 32 bit systems. Both should be available in your Start Menu.

Cloning RetroArch and libretro repositories[edit]

Once you are running the MSY2 MinGW-w64 Shell, then you will need to clone the RetroArch and libretro Git repositories.

git clone
cd libretro-super

This will fetch every repository in the libretro organization on Github into %MSYS2%/home/%USERNAME%/ . Since there are a lot of repositories to download, this will take a while to complete. You can use again to update all repositories, and you can fetch repositories individually by specifying their name e.g. ./ mednafen_psx

If you change a file in one of the cloned repositories and git won't let you update, do:

git reset --hard
git pull

It should update after that. If not, delete the whole repository and run again.

To change directories/folders do:

cd folder
cd folder/subfolder


To go up one directory:

cd ..

Other basic UNIX shell commands like "ls" can be useful as well.

Building RetroArch[edit]

To build RetroArch from the MSY2 MinGW-w64 Shell, execute the following:

cd libretro-super/retroarch && git pull && git submodule update --init && ./configure && make clean && make -j4

You should see a list of files being compiled, ending with LD retroarch. You can then copy the newly compiled retroarch.exe from libretro-super\retroarch to wherever you keep your RetroArch installation.

If you want to do a debug build, then execute the following:

make clean
make DEBUG=1 GL_DEBUG=1 -j4
mv retroarch.exe retroarch_debug.exe

This build will have all of the debug symbols intact and will be built with compiler optimizations turned off, so it can be run through a debugger like gdb.

If you are experiencing a missing DLL error, you can fetch all MSYS2 installed DLLs by executing this line:

for i in $(seq 3); do for bin in $(ldd *exe *dll | grep -i mingw | cut -d\  -f 3); do cp -vu "$bin" . ; done; done

Video filters and Audio DSP filters are compiled by going into gfx/filters and audio/filters, respectively, and running make on the Makefile. For example

cd retroarch
cd gfx/filters
make clean

After they build, you can copy the filters to your RetroArch installation.

Building libretro cores[edit]

After running the fetch script, you should have a folder for each libretro core in your libretro-super folder.

You can use to build all cores at once:

cd libretro-super

This will attempt to build almost every core available. This can take quite a while to complete, so you may wish to build cores individually:

cd libretro-super
./ mednafen_psx

The exact names for fetching or building individual cores can be found in the /rules.d/ script.

Cores that build successfully are put in /dist/win or /dist/win_x64 in your libretro-super folder. Be sure to run to update your local Git clones before building.

Building cores manually[edit]

If you wish, you can build cores manually if you want more control over the build process, though it's not recommended for inexperienced users. For most cores, all you need to do is do:

git pull
make -f Makefile.libretro clean
make -f Makefile.libretro -j4

If there isn't a Makefile or Makefile.libretro in the top level, try to find a "libretro" folder within the repository and there should be a Makefile in there. After the core is built, it will be in the same folder as the Makefile used to compile it.

The following need only make:

  • 4do-libretro
  • blastem-libretro
  • any 'beetle' source
  • cannonball
  • daphne
  • Dinothawr
  • FreeIntv
  • freej2me (inside /src/libretro)
  • Gearboy (inside /platforms/ibretro)
  • libretro-atari800
  • libretro-cap32
  • libretro-chailove
  • libretro-crocods
  • libretro-lutro
  • libretro-o2em
  • libretro-uae
  • melonDS
  • Mesen (inside /Libretro)
  • mrboom-libretro
  • mupen64plus-libretro
  • nestopia (inside /libretro)
  • nxengine-libretro
  • parallel-n64
  • ppsspp (inside /libretro)
  • prosystem-libretro
  • reicast-emulator
  • REminiscence
  • SameBoy (inside /libretro)
  • scummvm (inside /backends/platform/libretro/build)
  • snes9x (inside /libretro)
  • stella-libretro
  • tgbdual-libretro
  • theodore
  • virtualjaguar-libretro
  • yabause (inside /libretro)

The following need make -f Makefile.libretro:

  • 81-liberetro
  • blueMSX-libretro
  • Craft
  • desmume (inside /desmume)
  • dosbox-libretro
  • easyrpg-libretro (inside /builds/libretro)
  • fbalpha (NOTE: makefile.libretro is **all-lowercase**.)
  • fuse-libretro
  • gambatte-libretro
  • Genesis-Plus-GX
  • gw-libretro
  • Hatari
  • libretro-JamVM
  • libretro-meowPC98 (inside /libretro)
  • libretro-vecx
  • mgba
  • NP2kai (inside /sdl2)
  • picodrive
  • px68k-libretro
  • PokeMini
  • snes9x-next
  • vba-next

The following cores also require the running of git submodule update --init:

  • dolphin
  • libretro-ppsspp
  • picodrive

Some cores need special commands for building:


make profile='%PROFILE%' clean
make profile='%PROFILE%' -j4

Replace %PROFILE% with accuracy, balanced, or performance.


Dolphin requires Cmake now. Its information on the Libretro core is inside /Source/Core/DolphinLibretro.


cd libretro
make -f Makefile.%TARGET% MACHINE=%MACH%

Replace %TARGET% with the device to which you plan on building the core (e.g. linux-portable_x86_64, mingw_x86...) Replace %MACH% with any one of the following devices: chip8, gc, nes, sms.


If doing a 64-bit build.

cd libretro-mame
make -f Makefile.libretro PTR64=1 clean
make -f Makefile.libretro PTR64=1 -j4

This core will take a while to build, depending on how fast your CPU is, how many jobs you specify, and how many cores your CPU has. You can save some time updating the core by adding PARTIAL=1 when doing a clean. You can specify a subtarget by adding e.g. SUBTARGET=arcade or SUBTARGET=tiny in the current version of MAME.


Redream requires Cmake.


Rustation is written in Rust, not C or C++; neither make nor Cmake would work.

Building on Linux[edit]

Building on Linux is similar to building on Windows.

After entering the RetroArch folder, do:


...and install any necessary dependencies before running ./configure again. Then, do:


NOTE: Compilation may fail if you do not have the following installed:

  • g++
  • libgl1-mesa-dev
  • libsdl2-dev
  • mesa-common-dev
  • pkg-config

Also, you may need one of the following if RetroArch is to run audio:

  • alsa (libsdl2-dev)
  • libpulse (libpulse-dev)
  • lossaudo
  • lopenal (libopenal-dev)
  • jack
  • libroar (libroar-dev) WARNING: This might break your compilation.
  • rsound

Raspberry Pi[edit]

There is a tutorial on how to bypass X11 and use KMS, thus reducing overhead.

The above might work on regular desktop Linux, too.

Even so, if you plan on turning your Raspberry Pi into a "RetroArch machine", the easiest way is installing the RetroPie image. (You can also run its script.)