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: attempting to build native package with gomobile build mobile example fails with exit status 2 #30415

Closed
bubthegreat opened this issue Feb 26, 2019 · 8 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bubthegreat
Copy link

bubthegreat commented Feb 26, 2019

After installing and configuring android studio per their setup instructions, adding the SDK environment variables, and installing the additional dependencies (CMAKE, NDK, LLDB, platforms for 7.0+), attempts to run through the native package build steps fail with deprecation warnings.

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

Attempted in 1.11.4 and latest 1.12 (As of 2/26/2019)

PS C:\Users\bubth\Development> go version
go version go1.11.4 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
PS C:\Users\bubth\Development> go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\bubth\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\bubth\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\bubth\AppData\Local\Temp\go-build580209074=/tmp/go-build -gno-record-gcc-switches
PS C:\Users\bubth\Development>

Android SDK Info:

Android Studio 3.3.1
Build #AI-182.5107.16.33.5264788, built on January 28, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

What did you do?

PS C:\Users\bubth\Development> gomobile init
PS C:\Users\bubth\Development> gomobile build -target=android golang.org/x/mobile/example/basic
C:\Users\bubth\go\bin\gomobile.exe: go build -buildmode=c-shared -o C:\Users\bubth\AppData\Local\Temp\gomobile-work-069435679\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 2
# runtime/cgo
clang++.exe: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]
PS C:\Users\bubth\Development>

After updating to 1.12:

PS C:\Users\bubth\Development> go version
go version go1.12 windows/amd64
PS C:\Users\bubth\Development> go get golang.org/x/mobile/cmd/gomobile
PS C:\Users\bubth\Development> gomobile init
PS C:\Users\bubth\Development> go get -d golang.org/x/mobile/example/basic
PS C:\Users\bubth\Development> gomobile build -target=android golang.org/x/mobile/example/basic
C:\Users\bubth\go\bin\gomobile.exe: go build -buildmode=c-shared -o C:\Users\bubth\AppData\Local\Temp\gomobile-work-076420807\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 2
# runtime/cgo
clang++.exe: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]

PS C:\Users\bubth\Development>

What did you expect to see?

Successful build of the example mobile application.

What did you see instead?

Errors when attempting to build.

C:\Users\bubth\AppData\Local\Temp\gomobile-work-076420807\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 2
# runtime/cgo
clang++.exe: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]
@bcmills bcmills changed the title Attempting to build native package with gomobile build mobile example fails with exit status 2 x/mobile: attempting to build native package with gomobile build mobile example fails with exit status 2 Feb 27, 2019
@gopherbot gopherbot added this to the Unreleased milestone Feb 27, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Feb 27, 2019
@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed mobile Android, iOS, and x/mobile labels Feb 27, 2019
@bcmills
Copy link
Contributor

bcmills commented Feb 27, 2019

CC @hyangah @eliasnaur

@bcmills bcmills added the mobile Android, iOS, and x/mobile label Feb 27, 2019
@eliasnaur
Copy link
Contributor

See android/ndk#920. It seems the builtin compilers introduced in r19b are broken on Windows. One workaround is to use revision 8b05ea26b5669e5f52084ab001b8e49ec8877955 of gomobile which does not contain the change to use the new compilers.

@gopherbot
Copy link

Change https://golang.org/cl/164177 mentions this issue: cmd/gomobile: work around broken Windows NDK compiler scripts

@bubthegreat
Copy link
Author

For folks like me who are still learning golang and it's nuances, what's the simplest way to use that revision of gomobile? Would I be cherry picking a specific revision from the repo and rebuilding, or is there a simpler way?

@eliasnaur
Copy link
Contributor

You can apply my fix posted above or simply wait; it will probably be reviewed and merged soon enough and then a simple "go get -u golang.org/x/mobile/cmd/..." will do.

@eliasnaur
Copy link
Contributor

@bubthegreat please try again with the newest gomobile. Use go get -u golang.org/x/mobile/cmd/...to upgrade.

@wejoy
Copy link

wejoy commented Mar 5, 2019

@bubthegreat please try again with the newest gomobile. Use go get -u golang.org/x/mobile/cmd/...to upgrade.

It looks good now.

@bubthegreat
Copy link
Author

Verified working - thanks!

@golang golang locked and limited conversation to collaborators Mar 4, 2020
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#30415

Change-Id: I6cda312f465e05d28601432845c3c3d0f7a85605
Reviewed-on: https://go-review.googlesource.com/c/164177
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#30415

Change-Id: I6cda312f465e05d28601432845c3c3d0f7a85605
Reviewed-on: https://go-review.googlesource.com/c/164177
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants