Tutorial  Updated

Build and run RetroArch for Arch Linux (multi-consoles emulator)

This is a partial rewrite of the guide I wrote for r/SwitchHacks

Here is a short guide to quickly explain how to run RetroArch on Arch Linux on your Switch. RetroArch is a multi-platform multi-consoles emulator. It's basically like an empty shell in which you put your emulator ; they are called "cores". RetroArch loads a core for the desired console, which then loads and boots the game you feed it.

This is not a guide for using RetroArch, there are plenty out there. This is rather a guide to explain how to make it run on the Switch. You should build it yourself rather than using pre-compiled binaries because each binary is suited for the system it's been compiled on, in terms of features and drivers. For instance, if you don't have freetype or opengl installed you won't be able to use a RetroArch binary with XMB support enabled.

Anyway - I will assume that you already have a working copy of Arch Linux on your Switch, with sudo and GPU acceleration enabled. If you don't, go check my other guide (it's in this category). I will also assume that you know how to open and use a terminal (warning : gnome-terminal doesn't work yet).

To make the best out of RetroArch, I personnally recommend the KDE image that Gigaa made. I also recommend that you open a SSH terminal on your Switch, because you know, the onscreen keyboard is not very practical. Be aware that Wi-Fi and Bluetooth won't work at the same time, it will crash your console. Fixed with GNOME and KDE images.

List of known working cores :
  • vba-next
  • snes9x2010
  • beetle-psx (runs at approx. 50fps with "normal" power setting, however this causes power failures)
  • dosbox
List of known not working cores :
Building RetroArch

Code:
$ sudo pacman -S freetype2
$ sudo pacman -S base-devel
$ sudo pacman -S git
$ git clone --depth 1 https://github.com/libretro/RetroArch
$ cd RetroArch
$ ./configure
$ make

You can then run RetroArch with "./retroarch". It should start with the XMB menu working out of the box. To remove the black squares and add a nice font, go to the Online updater and download the assets. You can use RetroArch with the onscreen keyboard, although this is not very convenient.

You can improve performances of the XMB menu by going into Settings > User interface > Appearance and then disabling text shadows and using the simplified ribbon as a background.
Use backspace to go back in the menus. Escape will quit RetroArch. Don't thank me.

Building cores

As the buildbot doesn't contain the linux-aarch64 cores yet, you will have to build them yourself. Be careful as some cores need a JIT compiler to run at full performances (like parallel-n64) : they will need a "ARM64" JIT (simply "ARM" compilers will not work). If a core needs a JIT but don't offer a ARM64 / AARCH64 JIT, don't bother compiling it.

This being said - identify the core you want to build. I do this by going to the libretro organization on GitHub and typing in the name of the console I want the core of. Some consoles have a shitload of cores, just take the best one based on the date / description /last commit / README. Be careful as some cores have specific build instructions (typically written on the README).

For this example I will take vba-next, the libretro port of the VBA emulator (GBA). Just clone the corresponding repository and make the core :

Code:
$ git clone --depth 1 https://github.com/libretro/vba-next.git
$ cd vba-next
$ make

This will give you a file called "vba-next.so" : this is your core. To have it recognized by RetroArch, copy it in the right directory (run RA at least once so it creates it) :

Code:
$ cp vba-next.so ~/.config/retroarch/cores

You can then run RetroArch and load the core, then your game ! Enjoy <3
Feel free to report any core you tried, I'll add them to the list at the beginning of this post !
 
Last edited by natinusala,

DarkOrb

Well-Known Member
Member
Joined
Oct 11, 2013
Messages
290
Trophies
0
Age
31
XP
874
Country
Germany
Thank you for that tutorial. I might try it out once we have working joycon & sound support, otherwise it's not worth the trouble for me.
 
  • Like
Reactions: natinusala

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,785
Trophies
1
Age
44
XP
6,510
Country
Germany
I will try to make Lakka work on the Switch, with at least hardware acceleration and Wi-Fi in the first place.
I can imagine some end users who just want the Switch to be emulation heaven would love Lakka.
I prefer a full Ubuntu (or Debian) Gnome with RetroArch installed (among other things) though. :P
But yeah, Lakka on the Switch would be cool.
 

FatherOfEgg

Member
Newcomer
Joined
May 4, 2018
Messages
9
Trophies
0
Age
21
XP
102
Country
United States
Everytime I try to run RA, it gives me an error "xdg_runtime_dir not set in the environment". I must've been oblivious and done something wrong.
 

saneatsu

Well-Known Member
Newcomer
Joined
Apr 28, 2018
Messages
54
Trophies
0
Age
32
XP
209
Country
United States
I can imagine some end users who just want the Switch to be emulation heaven would love Lakka.
I prefer a full Ubuntu (or Debian) Gnome with RetroArch installed (among other things) though. :P
But yeah, Lakka on the Switch would be cool.
I wonder what HBL vs Linux performance difference would be. If we can just run this through HBL will we have aces to full/more efficient gpu api?
 

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
In order to run the cores through HBL we will need to port them and RetroArch. Once it's done for one core it can quite easily be done for all the others, but it's a pain.

Meanwhile, we have the lovely Lakka which is a super minimal OS (so improved performances) and everything ready out of the box.

Who would win ?

edit : we should also note that HBL is not ready for all consoles yet as Atmosphère is not released yet. Linux will (soon) be one SD card install and a one-shot boot script, even working from Android
 
Last edited by natinusala,

Miqote

Well-Known Member
Member
Joined
May 2, 2018
Messages
259
Trophies
0
XP
822
Country
Macedonia, The Former Yugoslav Republic of
I get this whenever I try to run RetroArch (both compiled and via pacman):

Code:
[alarm@kombos RetroArch]$ ./retroarch
libEGL warning: DRI2: failed to authenticate
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/dri)
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/dri)
gbm: failed to open any driver (search paths /usr/lib/dri)
gbm: Last dlopen error: /usr/lib/libLLVM-6.0.so: cannot read file data: Input/output error
failed to load driver: tegra
gbm: failed to open any driver (search paths /usr/lib/dri)
gbm: Last dlopen error: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory
failed to load driver: kms_swrast
gbm: failed to open any driver (search paths /usr/lib/dri)
gbm: Last dlopen error: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory
failed to load swrast driver
[alarm@kombos RetroArch]$

This is using the LXDE prebuilt image.
 

Skullkid707

New Member
Newbie
Joined
May 6, 2018
Messages
1
Trophies
0
Age
25
XP
76
Country
United States
I get this whenever I try to run RetroArch (both compiled and via pacman):

Code:
[alarm@kombos RetroArch]$ ./retroarch
libEGL warning: DRI2: failed to authenticate
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/dri)
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/dri)
gbm: failed to open any driver (search paths /usr/lib/dri)
gbm: Last dlopen error: /usr/lib/libLLVM-6.0.so: cannot read file data: Input/output error
failed to load driver: tegra
gbm: failed to open any driver (search paths /usr/lib/dri)
gbm: Last dlopen error: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory
failed to load driver: kms_swrast
gbm: failed to open any driver (search paths /usr/lib/dri)
gbm: Last dlopen error: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory
failed to load swrast driver
[alarm@kombos RetroArch]$

This is using the LXDE prebuilt image.

I get the same error can someone help that would be very appreciated
 

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
I've had this error once and it was fixed when I ran ./configure again without any parameter (before rebuilding everything obviously).
 

Miqote

Well-Known Member
Member
Joined
May 2, 2018
Messages
259
Trophies
0
XP
822
Country
Macedonia, The Former Yugoslav Republic of
I've had this error once and it was fixed when I ran ./configure again without any parameter (before rebuilding everything obviously).

Just did this, same result. I also cloned it into another directory and tried again, same thing. Are we sure this Arch Linux LXDE image has hardware acceleration?
 

Miqote

Well-Known Member
Member
Joined
May 2, 2018
Messages
259
Trophies
0
XP
822
Country
Macedonia, The Former Yugoslav Republic of
It works on the latest one-click GNOME but now my bluetooth gamepad won't connect.

It's always something!
 
D

Deleted User

Guest
[alarm@alarm RetroArch]$ ./RetroArch.sh

-bash: ./RetroArch.sh: No such file or directory

[alarm@alarm RetroArch]$ ./retroarch

failed to set tiling parameters: No such file or directory

failed to set tiling parameters: No such file or directory

Segmentation fault (core dumped)

[alarm@alarm RetroArch]$ sudo ./retroarch

error: XDG_RUNTIME_DIR not set in the environment.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: Sup