Long story short: every time I try to build something on the GameShell, installing dependencies breaks it. It’ll get stuck on the “LOADING…” screen and never actually enter the launcher. Even though I got RetroArch working a while ago, trying to compile it now using the same method breaks the GameShell. So after 6 re-flashes I’m thinking cross-compiling is the way to go.
My current test case is the Space Cadet Pinball decompilation, since it only depends on SDL2 and SDL_mixer. Starting from a live Debian USB, I do:
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt-get install git cmake libsdl2-dev:armhf libsdl2-mixer-dev:armhf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
git clone https://github.com/k4zmu2a/SpaceCadetPinball.git
I make a file in SpaceCadetPinball called gameshell.cmake:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Then back in the terminal:
cd SpaceCadetPinball
cmake -DCMAKE_TOOLCHAIN_FILE=gameshell.cmake .
make
The resulting SpaceCadetPinball binary wants a higher glibc version (currently 2.31) than the GameShell has on stock ClockworkOS 0.5 (2.28). Attempting set(CMAKE_EXE_LINKER_OPTIONS "-static")
fails with a bunch of undefined reference errors. sudo apt-get install libc6
on the GameShell breaks it again.
How am I supposed to compile for the GameShell?
1 Like
Out of curiosity, what version of Debian do you have currently installed? I feel like I had a similar issue where I had to downgrade the version of Debian to even run sudo apt-get update
on the device. Might be a separate issue, though.
The Gameshell is using ClockworkOS v0.5, lsb -a
reports it as being Debian 9.9. The live USB is using Debian 11.7. To get apt update
to work I had to download the Debian keyring, then install it with dpkg
on the GameShell.
I managed to find something that works for Space Cadet Pinball, at the very least. Got a lucky break, found this: GitHub - inolen/glibc_version_header: Build portable Linux binaries without using an ancient distro. It lets you link to old glibc versions and this fork works with ARM glibc 2.28, the version the GameShell uses. Here’s what I did as well as I can remember.
Start with the live Debian USB, open a terminal and enter:
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt-get install git cmake libsdl2-dev:armhf libsdl2-mixer-dev:armhf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
git clone https://github.com/k4zmu2a/SpaceCadetPinball.git
git clone https://github.com/inolen/glibc_version_header.git
In glibc_version_header, find force_link_glibc_2.28.h and drop it someplace easy to find. I just put it in the home directory, ~/
Here’s the updated gameshell.cmake:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
# New stuff
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ~/force_link_glibc_2.28.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ~/force_link_glibc_2.28.h")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
Then
cmake -DCMAKE_TOOLCHAIN_FILE=gameshell.cmake .
make
Copy the binary to the GameShell, chmod +x
, and it runs. I think it’s reproduceable, and it worked fine with SDL. Hopefully I can try it with more stuff later.
2 Likes
(I don’t know what the policy on double-posting on this forum is)
I tried compiling RetroArch similarly, but whenever I tried running it on the GameShell it gave me a unexpected PLT reloc type 0x00
error. Space Cadet Pinball had one of those which I think got fixed with -static-libgcc -static-libstdc++
but adding that to LDFLAGS doesn’t fix RA. Didn’t try compiling any cores.
I got some ideas from this Docker image but their solution was to base the image off of an old version of Ubuntu. Any other ideas?
I had to research this a bit, and I am not saying that I am correct. Based on the information you’ve provided, I would suggest the following steps:
- Instead of using the live Debian USB, set up a virtual machine (VM) or Docker container with the same version of Debian (9.9) as your GameShell’s ClockworkOS v0.5. This will help you ensure that the libraries and dependencies are as close as possible to the target system. This might help resolve the unexpected PLT reloc type error.
- Make sure you have the same version of libraries and dependencies in your VM or Docker container that is on your GameShell. This will help minimize compatibility issues.
- When compiling RetroArch, ensure that you are using the correct flags and options for cross-compilation, including the CMAKE_TOOLCHAIN_FILE and any other necessary flags.
- If you still face issues, consider compiling each core separately with the same method you used for Space Cadet Pinball, and see if that resolves the issue.
- Alternatively, you can consider using an older version of RetroArch or the required libraries if the newer versions are causing compatibility issues.
Please note that cross-compiling can be tricky and might require some trial and error. The key is to ensure that you are using the correct versions of libraries and dependencies, as well as the proper flags for cross-compilation.
Haven’t had a lot of time to keep experimenting with this. Would using a Debian 9.9 environment give the same issues about not installing packages that the GameShell itself has?
I did find this article which describes how to edit apt’s sources.list to pull from Debian archives, not the stable/oldstable repos. When I do the edits on the GameShell to point to the stretch archives, it can sudo apt update
just fine, no key errors or anything. Didn’t try installing/upgrading anything because I didn’t want to break and re-flash the GameShell yet again, but it seemed promising.