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: Failed to build GO app for android platform #29352

Open
mehulhirpara opened this issue Dec 20, 2018 · 1 comment

Comments

@mehulhirpara
Copy link

commented Dec 20, 2018

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

$ go version
go version go1.11.1 linux/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
GOARCH="amd64"
GOBIN="/home/mhirpara/work/go/bin"
GOCACHE="/home/mhirpara/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mhirpara/work/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build255459644=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Trying to compile below GO app, which include C calls, for android platform.

package main

// #include <unistd.h>
// int
// am_session_leader()
// {
//   return (getsid(0));
// }
import "C"
import (
	"fmt"
)

func main() {
	fmt.Println(C.am_session_leader())
}

What did you expect to see?

Expectation is to build this app for Android Platform, just like other platforms and should be able to run.

What did you see instead?

I see build errors as below:

# command-line-arguments
./main.go:7: error: undefined reference to 'getsid'
./main.go:7: error: undefined reference to 'getsid'
clang70: error: linker command failed with exit code 1 (use -v to see invocation)
# command-line-arguments
./main.go:7:12: warning: implicit declaration of function 'getsid' is invalid in C99 [-Wimplicit-function-declaration]

Commands:

GOOS=android GOARCH=arm GOROOT=/usr/lib/go CGO_ENABLED=1 CC=/home/mhirpara/work/go/pkg/gomobile/ndk-toolchains/arm/bin/arm-linux-androideabi-gcc go build main.go

OR

gomobile build -x -target=android github.com/mehulhirpara/learning/cgo-getsid

@mehulhirpara mehulhirpara changed the title Failed to build GO app for android platform x/mobile: Failed to build GO app for android platform Dec 20, 2018

@gopherbot gopherbot added this to the Unreleased milestone Dec 20, 2018

@gopherbot gopherbot added the mobile label Dec 20, 2018

@mehulhirpara

This comment has been minimized.

Copy link
Author

commented Dec 21, 2018

FYI, so far this issue is observed only for android/arm and not for android/arm64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.