Finally managed to successfully cross compile one of my work-in-progress emulators to clockworkOS so I figured maybe someone here could use some help with this.
Please note that this instructions only work for the Fbturbo driver. I would appreciate if someone has any directions on how to make this work for Lima, because that’s the most promising driver on clockworkOS.
There are several ways to build a cross compile toolchain, I used crosstool-ng. Simply follow the instructions on how to set up a toolchain from their Documentation page (pages 1-4). If you’re unsure about how to configure crosstool-ng, you can use my configuration available here. Some useful bits:
- GameShell machine name is
- Target OS is
- Version is
4.20.8(based on clockworkOS image 0.3)
- glibc version is
Once you have a cross compile toolchain (building takes a while), you’re ready to cross compile SDL2. Get the source code and run the following for the configuration and installation:
./configure --host=armv7l-unknown-linux-gnueabihf --build=x86_64-linux-gnu --disable-pulseaudio --prefix=/usr make chmod -R +w ~/x-tools/armv7l-unknown-linux-gnueabihf/armv7l-unknown-linux-gnueabihf/sysroot make DESTDIR=~/x-tools/armv7l-unknown-linux-gnueabihf/armv7l-unknown-linux-gnueabihf/sysroot install chmod -R -w ~/x-tools/armv7l-unknown-linux-gnueabihf/armv7l-unknown-linux-gnueabihf/sysroot
Your toolchain path might look different depending on your configuration. Finally, in order to compile your applications you can take some inspiration from this simple
CROSSTOOL_HOME := $(HOME)/x-tools/armv7l-unknown-linux-gnueabihf SYSROOT := $(CROSSTOOL_HOME)/armv7l-unknown-linux-gnueabihf/sysroot SDL_FLAGS := `$(SYSROOT)/usr/bin/sdl2-config --cflags` CXX := armv7l-unknown-linux-gnueabihf-g++ CXX_FLAGS := -Wall -Wextra -std=c++17 -ggdb3 $(SDL_FLAGS) BIN := bin SRC := src INCLUDE := include LIB := lib LIBRARIES := `$(SYSROOT)/usr/bin/sdl2-config --libs` EXECUTABLE := gs-cross-compile all: $(BIN)/$(EXECUTABLE) $(BIN)/$(EXECUTABLE): $(SRC)/*.cpp $(CXX) $(CXX_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES) clean: rm -rf $(BIN)/*
The only important part here is to use the cross compile toolchain of course and use the
sdl2-config binary inside your cross compile toolchain, this binary will correctly set the necessary flags for gcc.
Hope this helps someone, would love some feedback from people with more experience than me in embedded, this is my first time messing with this stuff.