Difference between revisions of "Building RetroArch"

From Emulation General Wiki
Jump to navigation Jump to search
(Rewrite this page)
Line 2: Line 2:
 
   
 
   
 
=Building on Windows=
 
=Building on Windows=
Note - the following is for 64-bit Windows only. 32-bit Windows will need to get 32-bit MinGW instead and use 32-bit headers and libs for RetroArch.
+
The recommended toolchain for building RetroArch on Windows is MinGW-w64 running inside the MSYS2 environment. Installers for MSYS2 can be found at [https://msys2.github.io/ msys2.github.io]. Other toolchains like TDM-GCC or Visual Studio can work, but this guide will only cover MSYS2.
  
Download the prepackaged toolchain from [http://themaister.net/retroarch-dl/MinGW-win64-RetroArch-dev-winpthread.7z here]. (Other versions of the mingw-w64 toolchain can be found [https://www.dropbox.com/sh/91sakv0qdyxjx9f/AAB2qJLK6v_UAvzXlwWI1hi4a/dev_tools?dl=0 here], but they may not have the Git Bash.vbs script)
+
==Preparing the environment==
  
Extract it somewhere, for example C:\MinGW.
+
Once you have installed MSYS2, you will need to update it and install the toolchain packages.
  
Run Git Bash.vbs. Then do the following commands:
+
===Updating MSYS2===
 +
 
 +
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
 +
 
 +
When the command is done working, close all MSYS2 shells you might have open and run these commands in the Run as dialog or in <code>cmd.exe</code>:
 +
 
 +
*In a 64bit install of MSYS2:
 +
 
 +
%systemdrive%\msys64\autorebase.bat
 +
 
 +
*In a 32bit install of MSYS2:
 +
 
 +
%systemdrive%\msys32\autorebase.bat
 +
 
 +
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===
 +
 
 +
TODO: find another way to install nvidia-cg-toolkit packages.
 +
 
 +
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-pkgconf mingw-w64-i686-nvidia-cg-toolkit 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-pkgconf mingw-w64-x86_64-nvidia-cg-toolkit 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
 +
 
 +
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==
 +
 
 +
Once you are running the MSY2 MinGW-w64 Shell, then you will need to clone the RetroArch and libretro Git repositories.
  
 
  git clone https://github.com/libretro/libretro-super.git
 
  git clone https://github.com/libretro/libretro-super.git
Line 14: Line 56:
 
  ./libretro-fetch.sh
 
  ./libretro-fetch.sh
  
You should now have all the libretro organization repositories cloned in the libretro-super folder within your MinGW folder. You can use libretro-fetch.sh again to update all repositories.
+
This will fetch every repository in the libretro organization on Github into <code>%MSYS2%/home/%USERNAME%/</code> . Since there are a lot of repositories to download, this will take a while to complete. You can use <code>libretro-fetch.sh</code> again to update all repositories, and you can fetch repositories individually by specifying their name e.g. <code>./libretro-fetch.sh mednafen_psx</code>
 
 
Just as a tip, always do a "git pull" to update the repository and "make clean" to clean up old build files before building anything. -j sets the number of jobs to do simultaneously, if you have a quad-core CPU, use -j4.  
 
  
 
If you change a file in one of the cloned repositories and git won't let you update, do:
 
If you change a file in one of the cloned repositories and git won't let you update, do:
Line 23: Line 63:
 
  git pull
 
  git pull
  
It should update after that. If not, delete the whole repository and run libretro-fetch.sh again.
+
It should update after that. If not, delete the whole repository and run <code>libretro-fetch.sh</code> again.
  
 
To change directories/folders do:
 
To change directories/folders do:
Line 39: Line 79:
 
Other basic UNIX shell commands like "ls" can be useful as well.
 
Other basic UNIX shell commands like "ls" can be useful as well.
  
===Using MSYS2 with mingw-w64===
+
==Building RetroArch==
  
You can use [http://sourceforge.net/projects/msys2/ MSYS2] to set up a mingw-w64 environment instead of using the prepackaged toolchain, which has a package manager for easy updating and installation. A guide to setting this up as well as a guide for making a Unix-like build can be found [https://gist.github.com/heuripedes/b6da0fea68b648bdd2ae#file-pure-msys2-build-md here].
+
Then execute these commands from the Git Bash shell:
 
 
==To build RetroArch:==
 
Download the [http://themaister.net/retroarch-dl/RetroArch-win64-headers.zip headers] and [http://themaister.net/retroarch-dl/RetroArch-win64-libs.zip libs] and extract them to the folder where the RetroArch repository was cloned (in \libretro-super\retroarch if you used the fetch script). Then execute these commands from the Git Bash shell:
 
  
 
  cd libretro-super
 
  cd libretro-super
 
  cd retroarch
 
  cd retroarch
 
  git pull
 
  git pull
  make -f Makefile.win clean
+
./configure
  make -f Makefile.win -j4
+
  make clean
 +
  make -j4
 +
 
 +
You should see a list of files being compiled, ending with <code>LD retroarch</code>. You can then copy the newly compiled <code>retroarch.exe</code> from <code>libretro-super\retroarch</code> to wherever you keep your RetroArch installation.
  
You should see a list of files being compiled, ending with "LD RetroArch.exe". You can then copy the newly compiled retroarch.exe and \tools\retroarch-joyconfig.exe from libretro-super\retroarch to wherever you keep your RetroArch installation.
+
If needed, you can fetch all MSYS2 installed DLLs, if you are experiencing a missing DLL error, by executing this line:
  
SoftFilters and Audio DSP filters are compiled by going into gfx/filters and audio/filters, respectively, and running make on the Makefile. For example
+
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 retroarch
Line 64: Line 106:
  
  
==To build libretro cores:==
+
==Building libretro cores==
  
 
After running the fetch script, you should have a folder for each libretro core in your libretro-super folder.
 
After running the fetch script, you should have a folder for each libretro core in your libretro-super folder.
  
Before you start building cores, you may need to set up your exports for some to build properly. If you're using the prepackaged toolchain, you will need to do this for libretro-build.sh to work:
+
You can use <code>libretro-build.sh</code> to build all cores at once:
 
 
export CC=gcc
 
export CXX=g++
 
export MAKE=make
 
 
 
These will be in effect until you close the Git Bash shell. You will have to set them again when you start it up again. To make this easier, create a shell script called [http://pastebin.com/P2bNTcFT exports.sh] (check the link for a suggested script), then you can run it with ".":
 
 
 
. exports.sh
 
 
 
You can put any exports you want or need in this script and they will be set.
 
 
 
You can use libretro-build.sh to build all cores at once:
 
  
 
  cd libretro-super
 
  cd libretro-super
Line 88: Line 118:
  
 
  cd libretro-super
 
  cd libretro-super
  ./libretro-build.sh build_libretro_bsnes
+
  ./libretro-build.sh mednafen_psx
  
The exact build_libretro calls can be found in the [https://github.com/libretro/libretro-super/blob/master/libretro-build.sh#L97 libretro-build.sh] script.
+
The exact names for fetching or building individual cores can be found in the [https://github.com/libretro/libretro-super/blob/master/rules.d/core-rules.sh /rules.d/core-rules.sh] script.
  
Cores that build successfully are put in /dist/win in your libretro-super folder. Be sure to run libretro-fetch.sh to update your local Git clones before building.
+
Cores that build successfully are put in <code>/dist/win</code> or <code>/dist/win_x64</code> in your libretro-super folder. Be sure to run <code>libretro-fetch.sh</code> to update your local Git clones before building.
  
 
==Building cores manually==
 
==Building cores manually==
  
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:
+
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
 
  git pull
Line 102: Line 132:
 
  make -f Makefile.libretro -j4
 
  make -f Makefile.libretro -j4
  
If there isn't a 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.
+
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.  
  
Refer to the [https://github.com/libretro/libretro-super/blob/master/libretro-build-common.sh libretro-build-common.sh] for exact commands for each core.
+
The following need only <code>make</code>:
 +
* 4do-libretro
 +
* any 'beetle' source
 +
* Dinothawr
 +
* dolphin (inside <code>/libretro</code>)
 +
* libretro-cap32
 +
* libretro-lutro
 +
* libretro-o2em
 +
* libretro-ppsspp (inside <code>/libretro</code>)
 +
* libretro-uae
 +
* mednfen-psx-libretro
 +
* nestopia (inside <code>/libretro</code>)
 +
* prosystem-libretro
 +
* stella
 +
* yabause (inside <code>/libretro</code>)
  
Some cores need special commands for building:
+
The following need <code>make -f Makefile.libretro</code>:
 +
* blueMSX-libretro
 +
* desmume (inside <code>/desmume</code>)
 +
* fuse-libretro
 +
* gambatte-libretro (inside <code>/libgambatte</code>)
 +
* Genesis-Plus-GX
 +
* gw-libretro
 +
* Hatari (You may need to run <code>./configure</code>)
 +
* mgba
 +
* picodrive
 +
* snes9x-next
 +
* vba-next
  
===bSNES Performance===
+
The following cores also require the running of <code>git submodule update --init</code>:
  
cd libretro-bsnes/perf
+
* dolphin
make ui='target-libretro' profile='performance' clean
+
* libretro-ppsspp
make ui='target-libretro' profile='performance' -j4
+
* picodrive
  
===bSNES Balanced===
+
Some cores need special commands for building:
 
 
cd libretro-bsnes/balanced
 
make ui='target-libretro' profile='balanced' clean
 
make ui='target-libretro' profile='balanced' -j4
 
 
 
===bSNES Accuracy===
 
 
 
cd libretro-bsnes
 
make ui='target-libretro' profile='accuracy' clean
 
make ui='target-libretro' profile='accuracy' -j4
 
  
===Mednafen===
+
===bsnes===
  
  cd libretro-mednafen
+
  cd libretro-bsnes_%PROFILE%
  make core=[CORE] clean
+
  make profile='%PROFILE%' clean
  make core=[CORE] -j4
+
  make profile='%PROFILE%' -j4
  
Replace [CORE] with psx for PlayStation, pce-fast for PC-Engine, wswan for WonderSwan, ngp for Neo-Geo Pocket, or vb for Virtual Boy.
+
Replace %PROFILE% with accuracy, balanced, or performance.
Do not bother with snes or gba, those cores do not function correctly on Windows and are based on old versions of bSNES and VBA-M.
 
 
 
===Mupen64plus===
 
 
 
To make a build with the dynarec available:
 
 
 
cd libretro-mupen64plus
 
make WITH_DYNAREC=x86_64 clean
 
make WITH_DYNAREC=x86_64 -j4
 
  
 
===MAME===
 
===MAME===
 +
If doing a 64-bit build.
  
Download and install [http://www.python.org/ftp/python/2.7.5/python-2.7.5.amd64.msi Python 2.7.5] to the default location.
+
cd libretro-mame
 
+
  make -f Makefile.libretro PTR64=1 clean
Then do:
+
  make -f Makefile.libretro PTR64=1 -j4
 
 
  make -f Makefile.libretro TARGET=mame PTR64=1 PYTHON="C:/Python27/pythonw.exe" clean
 
  make -f Makefile.libretro TARGET=mame PTR64=1 PYTHON="C:/Python27/pythonw.exe" -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 also build MESS and UME by changing TARGET to "mess" and "ume" respectively.
 
  
=Libretro-super=
+
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. <code>SUBTARGET=arcade</code> or <code>SUBTARGET=tiny</code> in the current version of MAME.
 
 
Libretro-super is a series of scripts used to ease the compilation and installation of each and every libretro emulation core and RetroArch itself. Thus this is the simplest route to a fully functional installation. If you need or want to build each core individually then you can refer to the [https://github.com/libretro/libretro-super/blob/master/libretro-build-common.sh build-common.sh] script for direction.
 
git clone git://github.com/libretro/libretro-super.git
 
cd libretro-super
 
sh libretro-fetch.sh
 
sh libretro-build.sh
 
sh libretro-install.sh <path where you'd like RetroArch installed>
 
  
 
=Building on Linux=
 
=Building on Linux=
Line 201: Line 226:
  
 
Even so, if you plan on turning your Raspberry Pi into a "RetroArch machine", the easiest way is installing the [http://blog.petrockblock.com/retropie/retropie-downloads/ RetroPie image]. (You can also run [http://blog.petrockblock.com/2012/07/22/retropie-setup-an-initialization-script-for-retroarch-on-the-raspberry-pi/ its script].)
 
Even so, if you plan on turning your Raspberry Pi into a "RetroArch machine", the easiest way is installing the [http://blog.petrockblock.com/retropie/retropie-downloads/ RetroPie image]. (You can also run [http://blog.petrockblock.com/2012/07/22/retropie-setup-an-initialization-script-for-retroarch-on-the-raspberry-pi/ its script].)
 
=Making Cores=
 
 
Some cores simply need that you run 'make'. Others require you to run 'make -f Makefile.libretro'. Sometimes, the makefile may be in a subfolder, usually called 'libretro'.
 
 
'''WARNING: the following lists are incomplete.'''
 
 
The following need only 'make':
 
* 4do-libretro
 
* any 'beetle' source
 
* Dinothawr
 
* dolphin (inside /libretro)
 
* libretro-cap32
 
* libretro-lutro
 
* libretro-o2em
 
* libretro-ppsspp (inside /libretro)
 
* libretro-uae
 
* mednfen-psx-libretro
 
* nestopia (inside /libretro)
 
* prosystem-libretro
 
* stella
 
* yabause (inside /libretro)
 
 
The following need 'make -f Makefile.libretro':
 
* blueMSX-libretro
 
* desmume (inside /desmume)
 
* fuse-libretro
 
* gambatte-libretro (inside /libgambatte)
 
* Genesis-Plus-GX
 
* gw-libretro
 
* Hatari (You may need to run ./configure)
 
* mgba
 
* picodrive
 
* snes9x-next
 
* vba-next
 
 
The following cores also require the running of 'git submodule update --init':
 
 
* dolphin
 
* libretro-ppsspp
 
* picodrive
 
  
 
[[Category:FAQs]]
 
[[Category:FAQs]]
 
[[Category:RetroArch]]
 
[[Category:RetroArch]]

Revision as of 02:57, 2 February 2016

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

Building on Windows

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

Preparing the environment

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

Updating MSYS2

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

When the command is done working, close all MSYS2 shells you might have open and run these commands in the Run as dialog or in cmd.exe:

  • In a 64bit install of MSYS2:
%systemdrive%\msys64\autorebase.bat
  • In a 32bit install of MSYS2:
%systemdrive%\msys32\autorebase.bat

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

TODO: find another way to install nvidia-cg-toolkit packages.

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-pkgconf mingw-w64-i686-nvidia-cg-toolkit 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-pkgconf mingw-w64-x86_64-nvidia-cg-toolkit 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

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

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

git clone https://github.com/libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh

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 libretro-fetch.sh again to update all repositories, and you can fetch repositories individually by specifying their name e.g. ./libretro-fetch.sh 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 libretro-fetch.sh again.

To change directories/folders do:

cd folder
or
cd folder/subfolder

etc.

To go up one directory:

cd ..

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

Building RetroArch

Then execute these commands from the Git Bash shell:

cd libretro-super
cd retroarch
git pull
./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 needed, you can fetch all MSYS2 installed DLLs, if you are experiencing a missing DLL error, 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
make

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


Building libretro cores

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

You can use libretro-build.sh to build all cores at once:

cd libretro-super
./libretro-build.sh

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
./libretro-build.sh mednafen_psx

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

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

Building cores manually

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
  • any 'beetle' source
  • Dinothawr
  • dolphin (inside /libretro)
  • libretro-cap32
  • libretro-lutro
  • libretro-o2em
  • libretro-ppsspp (inside /libretro)
  • libretro-uae
  • mednfen-psx-libretro
  • nestopia (inside /libretro)
  • prosystem-libretro
  • stella
  • yabause (inside /libretro)

The following need make -f Makefile.libretro:

  • blueMSX-libretro
  • desmume (inside /desmume)
  • fuse-libretro
  • gambatte-libretro (inside /libgambatte)
  • Genesis-Plus-GX
  • gw-libretro
  • Hatari (You may need to run ./configure)
  • mgba
  • picodrive
  • 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:

bsnes

cd libretro-bsnes_%PROFILE%
make profile='%PROFILE%' clean
make profile='%PROFILE%' -j4

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

MAME

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.

Building on Linux

Building on Linux is similar to building on Windows.

After entering the RetroArch folder, do:

./configure

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

make


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

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

https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=56070

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.)