Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: build doesn't include libc++_shared.so to produced .apk and app immediately crashes upon start #44897

Open
the-goodies opened this issue Mar 9, 2021 · 3 comments

Comments

@the-goodies
Copy link

@the-goodies the-goodies commented Mar 9, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Gedis\AppData\Local\go-build
set GOENV=C:\Users\Gedis\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Gedis\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Gedis\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Gedis\workspace\gomobile\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Gedis\AppData\Local\Temp\go-build3903890372=/tmp/go-build -gno-record-gcc-switches

What did you do?

I was trying basic gomobile example (golang.org/x/mobile/example/basic copied to my own module) by running: "gomobile install basic" and it produced basic.apk and it ran fine on a real device.

Then to the same basic example main.go file, I added only a single CGO library import: _ "github.com/inkyblackness/imgui-go/v4" to see if it compiles and works. It compiled without any errors and app installed to the real device, but when running it, it immediately crashed.

To see what error's this crash produced, I ran adb logcat --buffer=crash and heres the output:
03-09 23:58:36.606 16313 16313 E AndroidRuntime: FATAL EXCEPTION: main
03-09 23:58:36.606 16313 16313 E AndroidRuntime: Process: org.golang.todo.network, PID: 16313
03-09 23:58:36.606 16313 16313 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at java.lang.System.loadLibrary(System.java:1669)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at org.golang.app.GoNativeActivity.load(GoNativeActivity.java:56)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at org.golang.app.GoNativeActivity.onCreate(GoNativeActivity.java:64)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:7327)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:7318)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3094)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3257)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:214)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7050)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
03-09 23:58:36.606 16313 16313 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

It seems like libc++_shared.so library is missing. I tried to search how I can include this with gomobile or some other way, but failed.
Is it possible to add/link this library or I'm doing something wrong and culprit is somewhere else? Thanks.

@the-goodies the-goodies changed the title gomobile build fails to include c++_shared.so to produced app and this app upon start immediately crashes gomobile build fails to include libc++_shared.so to produced app and this app upon start immediately crashes Mar 9, 2021
@the-goodies the-goodies changed the title gomobile build fails to include libc++_shared.so to produced app and this app upon start immediately crashes x/mobile/cmd/gomobile: build doesn't include libc++_shared.so to produced .apk and app immediately crashes upon start Mar 10, 2021
@gopherbot gopherbot added the mobile label Mar 10, 2021
@gopherbot gopherbot added this to the Unreleased milestone Mar 10, 2021
@toothrot toothrot changed the title x/mobile/cmd/gomobile: build doesn't include libc++_shared.so to produced .apk and app immediately crashes upon start x/mobile: build doesn't include libc++_shared.so to produced .apk and app immediately crashes upon start Mar 11, 2021
@toothrot
Copy link
Contributor

@toothrot toothrot commented Mar 11, 2021

@eliasnaur
Copy link
Contributor

@eliasnaur eliasnaur commented Mar 11, 2021

This may be a gomobile bug, but it's probably better to bring it up with the inkyblackness/imgui-go developers to see whether they support Android. And if so, how.

@the-goodies
Copy link
Author

@the-goodies the-goodies commented Mar 12, 2021

inkyblackness/imgui-go doesn't explicitly support Android. It's a pure Dear ImGui bindings library, with no platform or backend layer (there's a separate repository with glfw/sdl and opengl2/3 examples: https://github.com/inkyblackness/imgui-go-examples).
I have a need to create an Android app and at first I tried Flutter, but didn't really like it: dart language, state management is a mess compared to imgui (at least to me it looked way overcomplicated).
Afterwards was thinking maybe I should just use Dear ImGui with C++ (pull request for Android backend was merged like a week ago), since I'm really comfortable with imgui-go and use it a lot for desktop programs. Seems like a decent choice, but it's C++ language, not Go, so I'm hesitant (might still choose this option).
Then we arrive at a current issue where I try imgui-go with gomobile (before hand I didn't even know that gomobile exists) and was kind of hopeful that it could work, because then I could use both Go and ImGui, but it crashes. Was trying various ways to include this libc++_shared.so, but nothing worked.
Anyway, since this issue might not be resolved (at least not soon enough), I still think it could be great to use Go, so next I will try to use your Gio library. It's approach is imgui too and provided sample examples felt good on a touchscreen. So far looks promising and might be good for what I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants