You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a prototype android google cardboard app that will need to use OpenGL ES 3.0/3.1 and most of the application is written in Go. I had a prototype up and running using OpenGL ES 2.0 but when I made the switch to ES 3.0 I found that I needed to write my own wrappers. I used the following block at the beginning of the wrapper to include the gl3.h header file:
What happened was that I would get error messages when compiling in Android Studio with the gomobile bind portion of the process stating that it couldn't find the <GLES3/glh3.h> file.
When I investigated, it turns out that gomobile init for android arm always uses platform-15 from the NDK -- this platform version doesn't include the GLES3 headers because it doesn't support OpenGL ES 3.0 (requires platform 18+, per http://developer.android.com/guide/topics/graphics/opengl.html)
The Hack
I changed mobile/cmd/gomobile/env.go ndkConfig to point to platform-19.
I changed mobile/cmd/gomobile/init.go useStrippedNDK to false so that it would download the full NDK as the stripped version doesn't have the platform minimum I needed.
With these changes a fresh gomobile init caused me to have the right platform headers in $GOPATH/pkg/gomobile/android-ndk-r10e/arm/sysroot/usr/include as well as the right libs in the parallel lib directory. From there I was able to compile the OpenGL ES 3.0 wrapper I was making and run the compiled app on my phone using specific gles3 shaders and functions.
What I Wanted To See
After I found the problem to be that gomobile init always uses the same platform, I think the best solution for me would be to have a flag for gomobile init to specify the platform level to support and another flag to control whether or not the full NDK is downloaded so that you don't have to modify the source code.
System Details
go version go1.6 windows/amd64
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:/gocode
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
The text was updated successfully, but these errors were encountered:
I don't think we should repack and redistribute all NDK versions for gomobile. Instead, users should be enabled to to target a specific standalone NDK toolchain by setting some env variables similar to CC and CXX.
If https://golang.org/cl/99316 goes in, you should be able to work around this problem by using gobind instead of gomobile and then building the JNI libraries manually. The CL includes a short example, and you can specify the platform version when you generate the standalone NDK toolchain.
andybons
changed the title
x/mobile/cmd/gomobile init doesn't allow for android NDK platform selection
x/mobile/cmd/gomobile: init doesn't allow for android NDK platform selection
May 14, 2019
andybons
added
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
labels
May 14, 2019
The Problem
I'm working on a prototype android google cardboard app that will need to use OpenGL ES 3.0/3.1 and most of the application is written in Go. I had a prototype up and running using OpenGL ES 2.0 but when I made the switch to ES 3.0 I found that I needed to write my own wrappers. I used the following block at the beginning of the wrapper to include the gl3.h header file:
What happened was that I would get error messages when compiling in Android Studio with the gomobile bind portion of the process stating that it couldn't find the
<GLES3/glh3.h>
file.When I investigated, it turns out that
gomobile init
for android arm always uses platform-15 from the NDK -- this platform version doesn't include the GLES3 headers because it doesn't support OpenGL ES 3.0 (requires platform 18+, per http://developer.android.com/guide/topics/graphics/opengl.html)The Hack
mobile/cmd/gomobile/env.go
ndkConfig to point to platform-19.mobile/cmd/gomobile/init.go
useStrippedNDK tofalse
so that it would download the full NDK as the stripped version doesn't have the platform minimum I needed.With these changes a fresh
gomobile init
caused me to have the right platform headers in$GOPATH/pkg/gomobile/android-ndk-r10e/arm/sysroot/usr/include
as well as the right libs in the parallel lib directory. From there I was able to compile the OpenGL ES 3.0 wrapper I was making and run the compiled app on my phone using specific gles3 shaders and functions.What I Wanted To See
After I found the problem to be that
gomobile init
always uses the same platform, I think the best solution for me would be to have a flag forgomobile init
to specify the platform level to support and another flag to control whether or not the full NDK is downloaded so that you don't have to modify the source code.System Details
go version go1.6 windows/amd64
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:/gocode
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
The text was updated successfully, but these errors were encountered: