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: Cannot get `gomobile bind` to work with the canonical example #21203

Closed
paulcolea opened this issue Jul 28, 2017 · 6 comments

Comments

Projects
None yet
6 participants
@paulcolea
Copy link

commented Jul 28, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.3 darwin/amd64

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

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

I tried to follow the basic gomobile bind example on https://github.com/golang/go/wiki/Mobile, and ran:

gomobile build -target=ios golang.org/x/mobile/example/basic

What did you expect to see?

That the example would work and an iOS library would be built.

What did you see instead?

gomobile: go install -pkgdir=/Users/paulcolea/go/pkg/gomobile/pkg_darwin_arm -tags ios golang.org/x/mobile/example/bind/hello failed: exit status 2
go: GOPATH entry is relative; must be absolute path: "".
For more details see: 'go help gopath'

When checking the GOPATH, I can see it's correctly set:

[17:09:47 - 17-07-28] /Users/paulcolea/go/src/golang.org/x/mobile/example/bind % go env GOPATH
/Users/paulcolea/go

@bradfitz bradfitz changed the title Cannot get `gomobile bind` to work with the canonical example x/mobile: Cannot get `gomobile bind` to work with the canonical example Jul 28, 2017

@gopherbot gopherbot added this to the Unreleased milestone Jul 28, 2017

@gopherbot gopherbot added the mobile label Jul 28, 2017

@OneOfOne

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2017

What does go env print, the full output, not just arch.

@hyangah

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2017

Does -x -v options output more info?

@paulcolea

This comment has been minimized.

Copy link
Author

commented Jul 31, 2017

BTW in my bug report I meant to say that i used gomobile bind instead of gomobile build, my apologies for any confusion caused.

@OneOfOne, here's what go env outputs:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/paulcolea/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7h/_z6wzdj13q788sl9dfb6qd84007fv6/T/go-build658723982=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

@hyangah - I reran using -x -v and here's what I'm getting, I can't make anything new of this output:

[9:57:41 - 17-07-31] /usr/bin % gomobile bind -x -v -target=ios golang.org/x/mobile/example/bind/hello
GOMOBILE=/Users/paulcolea/go/pkg/gomobile
WORK=/var/folders/7h/_z6wzdj13q788sl9dfb6qd84007fv6/T/gomobile-work-916204126
write /var/folders/7h/_z6wzdj13q788sl9dfb6qd84007fv6/T/gomobile-work-916204126/src/gomobile_bind/interfaces.go
mkdir -p $WORK/src/gomobile_bind
write /var/folders/7h/_z6wzdj13q788sl9dfb6qd84007fv6/T/gomobile-work-916204126/gen/src/ObjC/interfaces.go
mkdir -p $WORK/gen/src/ObjC
write /var/folders/7h/_z6wzdj13q788sl9dfb6qd84007fv6/T/gomobile-work-916204126/src/gomobile_bind/interfaces.h
mkdir -p $WORK/src/gomobile_bind
write /var/folders/7h/_z6wzdj13q788sl9dfb6qd84007fv6/T/gomobile-work-916204126/src/gomobile_bind/interfaces.m
mkdir -p $WORK/src/gomobile_bind
GOOS=darwin GOARCH=arm GOARM=7 CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CGO_CFLAGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -miphoneos-version-min=6.1 -arch armv7 CGO_LDFLAGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -miphoneos-version-min=6.1 -arch armv7 CGO_ENABLED=1 GOPATH=$WORK/gen: go install -pkgdir=$GOMOBILE/pkg_darwin_arm -tags ios -v -x golang.org/x/mobile/example/bind/hello
go: GOPATH entry is relative; must be absolute path: "".
For more details see: 'go help gopath'
rm -r -f "$WORK"
gomobile: go install -pkgdir=/Users/paulcolea/go/pkg/gomobile/pkg_darwin_arm -tags ios -v -x golang.org/x/mobile/example/bind/hello failed: exit status 2
@oliverFU

This comment has been minimized.

Copy link

commented Aug 1, 2017

Hey,

I had the same problem and the solution:

Just add the following lines to ~/.bashrc and this will persist. However, you can use other paths you like as GOPATH instead of $HOME/go in my sample.

export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Source: https://stackoverflow.com/questions/21001387/how-do-i-set-the-gopath-environment-variable-on-ubuntu-what-file-must-i-edit#21012349

Cheers

@paulcolea

This comment has been minimized.

Copy link
Author

commented Aug 3, 2017

Thanks so much @oliverFU! This solved my problem indeed :)

@paulcolea paulcolea closed this Aug 3, 2017

@Eonlychen

This comment has been minimized.

Copy link

commented Dec 28, 2017

@paulcolea i had the same problem with you, but it still didn't work using above method, can you tell me why? please

@golang golang locked and limited conversation to collaborators Dec 28, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.