raylib-go icon indicating copy to clipboard operation
raylib-go copied to clipboard

Running raylib examples in termux

Open softkot opened this issue 1 month ago • 6 comments

Tyting to code some ideas with raylib inside termux but at first it fails to compile:

$ git clone https://github.com/gen2brain/raylib-go.git && go -C raylib-go/examples/games/life run .


# github.com/gen2brain/raylib-go/raylib
In file included from raudio.c:221:
./external/stb_vorbis.c:1404:75: warning: pointer comparison always evaluates to false [-Wtautological-compare]
# github.com/gen2brain/raylib-go/raylib
In file included from rcore.c:561:
./platforms/rcore_android.c:940:81: error: incompatible pointer to integer conversion passing 'ANativeWindow *' (aka 'struct ANativeWindow *') to parameter of type 'EGLNativeWindowType' (aka 'unsigned long') [-Wint-conversion]
../../../../../usr/bin/../../usr/include/EGL/egl.h:136:109: note: passing argument to parameter 'win' here
In file included from rcore.c:561:
./platforms/rcore_android.c:1004:97: error: incompatible pointer to integer conversion passing 'ANativeWindow *' (aka 'struct ANativeWindow *') to parameter of type 'EGLNativeWindowType' (aka 'unsigned long') [-Wint-conversion]
../../../../../usr/bin/../../usr/include/EGL/egl.h:136:109: note: passing argument to parameter 'win' here

It is possible to overcome this error turning it to warning but it fails to start with segfault

CGO_CFLAGS="-Wno-int-conversion -Wno-tautological-compare"  go -C raylib-go/examples/games/life run .

signal: segmentation fault

Did i miss something simple to make it run?

softkot avatar Oct 31 '25 10:10 softkot

The Android implementation is different than standard desktop. It has its own custom entry point, it uses NativeActivity, and it must be compiled to a dynamic library that is then loaded from the standard Android manifest. Check the Android example in this repository; what you are trying to do will, of course, not work like that.

gen2brain avatar Oct 31 '25 10:10 gen2brain

in fact i was trying build it running as X11 application in termux-x11

CGO_CFLAGS="-Wno-int-conversion -Wno-tautological-compare"  go -C raylib-go/examples/games/life run -tags x11 .

did segfault too

softkot avatar Oct 31 '25 11:10 softkot

The build constraints/tags for Android in files are forcing it to use an Android path, not a desktop path.

gen2brain avatar Oct 31 '25 11:10 gen2brain

The question is any way to run an example targeting termux-x11 ?

softkot avatar Oct 31 '25 11:10 softkot

I.e., linux && !android and androd && !linux. The android is "special" in Go because it can be built for both linux and android tags. That is why it is done like that.

Now that I've explained it, you can make the necessary changes and test it yourself.

gen2brain avatar Oct 31 '25 11:10 gen2brain

Just a note, if you can make it work, the current build tags should stay, but we can introduce, e.g., termux build tag that will use X11 on the Android platform and behave like on the desktop.

gen2brain avatar Oct 31 '25 12:10 gen2brain