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: gomobile binding failed due to lack of some header file in Android NDK #39549

Open
ChronosX88 opened this issue Jun 12, 2020 · 11 comments
Open

Comments

@ChronosX88
Copy link

@ChronosX88 ChronosX88 commented Jun 12, 2020

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

$ go version
go version go1.14.4 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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/chronosx/.cache/go-build"
GOENV="/home/chronosx/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/chronosx/Документы/code/golang/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/snap/go/5830"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/5830/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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-build278490309=/tmp/go-build -gno-record-gcc-switches"

Android NDK version: 21.3.6528147

Gomobile version: gomobile version +4c31acb Sun Mar 29 12:56:38 2020 +0000 (android); androidSDK=

(I'm tried to use Go from Ubuntu repos, not only from Snap)

What did you do?

I'm trying to build some library which written in Go for Android (build AAR file).

gomobile: go build -tags mobile -ldflags -X github.com/yggdrasil-network/yggdrasil-go/src/version.buildName=yggdrasil -X github.com/yggdrasil-network/yggdrasil-go/src/version.buildVersion=0.3.14 -s -w  -buildmode=c-shared -o=/tmp/gomobile-work-131080533/android/src/main/jniLibs/armeabi-v7a/libgojni.so ./gobind failed: exit status 2
# runtime/cgo
gcc_android.c:6:10: fatal error: 'android/log.h' file not found

The file android/log.h exists in Android NDK.

What did you expect to see?

Library will compile successfully (it was compiled fine before).

What did you see instead?

I got the error:

gcc_android.c:6:10: fatal error: 'android/log.h' file not found
@gopherbot gopherbot added the mobile label Jun 12, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2020
@toothrot
Copy link
Contributor

@toothrot toothrot commented Jun 12, 2020

/cc @hyangah

@mirza-s
Copy link

@mirza-s mirza-s commented Jul 6, 2020

@ChronosX88

Are you building under $GOPATH? Building with go modules outside of $GOPATH might be the issue here.

@ChronosX88
Copy link
Author

@ChronosX88 ChronosX88 commented Jul 7, 2020

@ChronosX88

Are you building under $GOPATH? Building with go modules outside of $GOPATH might be the issue here.

@mirza-s

I'm building the AAR file under $GOPATH, but error still exists.

@ChronosX88
Copy link
Author

@ChronosX88 ChronosX88 commented Aug 18, 2020

Any updates?

@hajimehoshi
Copy link
Member

@hajimehoshi hajimehoshi commented Oct 26, 2020

Have you set ANDROID_NDK_HOME environment variable?

@ChronosX88
Copy link
Author

@ChronosX88 ChronosX88 commented Oct 26, 2020

Have you set ANDROID_NDK_HOME environment variable?

@hajimehoshi Yes, I've set all necessary environment variables.

ANDROID_NDK_HOME file listing:
изображение

@hajimehoshi
Copy link
Member

@hajimehoshi hajimehoshi commented Oct 26, 2020

I've never tried to develop Android application on Linux so I don't have a good insight. Does regular Android application development work in your environment?

@ChronosX88
Copy link
Author

@ChronosX88 ChronosX88 commented Oct 26, 2020

I've never tried to develop Android application on Linux so I don't have a good insight. Does regular Android application development work in your environment?

Yep, regular Android app is building correctly.

@ChronosX88
Copy link
Author

@ChronosX88 ChronosX88 commented Oct 26, 2020

By the way, I know the location of log.h file (it is under $NDK/sysroot/usr/include/android dir). How to specify include dir for

#include <android/log.h>
? May be I should add some env vars, or smth like this?

@ChronosX88
Copy link
Author

@ChronosX88 ChronosX88 commented Oct 26, 2020

The similar error appears in #14398.

@hajimehoshi
Copy link
Member

@hajimehoshi hajimehoshi commented Oct 27, 2020

I don't think we really need it but how about setting C_INCLUDE_PATH?

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
5 participants