Is it possible to build Android games in Go using the NDK using cgo and / or SWIG or similar?

Is it possible to use Go to create Android games? I am not attached to the technologies mentioned in the topic. I know that some people created some Android programs in Go, but they may have been headless.

+6
source share
2 answers

No, this is not possible right now. Go and C programs can interact through cgo. but in this case, the Go program must start and initialize its working environment before transferring control to part C of the C-based program.

When using NDK on Android, your C code is invoked by the Dalvik virtual machine via dlopen. Thus, the Go runtime will not be able to initialize itself.

+1
source

If you want to use headless applications, my advice would be to use cgo for the GUI. This sounds illogical, but if the NDK supports ci-vid libraries, then it is probably easiest to write a GUI using these calls. Of course, you don’t need to write all the logic in C. You could just cgo wrappers for each of the GUI calls, and then write a GUI in go, except that every gui call will be translated through cgo.

-1
source

Source: https://habr.com/ru/post/919805/


All Articles