Open ChronosXYZ opened 4 years ago
/cc @hyangah
@ChronosX88
Are you building under $GOPATH? Building with go modules outside of $GOPATH might be the issue here.
@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.
Any updates?
Have you set ANDROID_NDK_HOME
environment variable?
Have you set
ANDROID_NDK_HOME
environment variable?
@hajimehoshi Yes, I've set all necessary environment variables.
ANDROID_NDK_HOME
file listing:
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?
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.
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 https://github.com/golang/go/blob/751c37fd629e0ebb18c39a219fab2b224d016b70/src/runtime/cgo/gcc_android.c#L6 ? May be I should add some env vars, or smth like this?
The similar error appears in https://github.com/golang/go/issues/14398.
I don't think we really need it but how about setting C_INCLUDE_PATH
?
I was able to fix this by setting the CC
variable : export CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android21-clang
for x86
I'm also seeing this issue using the most recent gomobile
commit(https://github.com/golang/mobile/commit/8578da9835fd365e78a6e63048c103b27a53a82c):
gomobile: gobind -lang=go,java -outdir=/build/gomobile-work github.com/status-im/go-waku/mobile failed: exit status 1
2022/06/09 16:15:42 err: exit status 2: stderr: go: downloading github.com/multiformats/go-multiaddr v0.5.0
go: downloading github.com/status-im/go-ethereum v1.10.4-status.2
go: downloading github.com/cruxic/go-hmac-drbg v0.0.0-20170206035330-84c46983886d
go: downloading github.com/libp2p/go-libp2p-core v0.16.1
go: downloading go.uber.org/zap v1.21.0
go: downloading github.com/libp2p/go-libp2p v0.20.0
go: downloading github.com/libp2p/go-libp2p-pubsub v0.6.1
go: downloading github.com/status-im/go-waku-rendezvous v0.0.0-20211018070416-a93f3b70c432
go: downloading go.opencensus.io v0.23.0
go: downloading github.com/libp2p/go-msgio v0.2.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/btcsuite/btcd/btcec/v2 v2.1.3
go: downloading golang.org/x/sync v0.0.0-20220513210516-0976fa681c29
go: downloading github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e
go: downloading github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
go: downloading github.com/golang-migrate/migrate/v4 v4.15.2
# runtime/cgo
gcc_android.c:6:10: fatal error: android/log.h: No such file or directory
6 | #include <android/log.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
I'm using NDK version 22.1.7171670
to build an AAR which works just fine for another application.
What's interesting is when I strace
the build, I can see there are two attempts by two separate GCC processes:
> grep 'gcc_android.*fatal' /nix/store/aqf11zrgdzh0i4zr8gvdzk5b6hpiwrix-go-waku-devel/strace.log
535 write(2, "gcc_android.c:6:10: fatal error:"..., 140) = 140
347 <... read resumed>"gcc_android.c:6:10: fatal error:"..., 512) = 140
763 write(2, "gcc_android.c:6:10: fatal error:"..., 140) = 140
574 <... read resumed>"gcc_android.c:6:10: fatal error:"..., 512) = 140
> grep 'gcc_android.*fatal' /nix/store/p1zh5y4bx9fg0hd47lwkr4k7ja01ind0-status-go-0.101.0-09ba88c-android/strace.log
296 write(2, "gcc_android.c:6:10: fatal error:"..., 140) = 140
97 <... read resumed>"gcc_android.c:6:10: fatal error:"..., 512) = 164
525 write(2, "gcc_android.c:6:10: fatal error:"..., 140) = 140
328 <... read resumed>"gcc_android.c:6:10: fatal error:"..., 512) = 140
Except in the case of the latter, it continues and eventually builds it using android/log.h
from Android SDK:
1663 openat(AT_FDCWD, "/nix/store/w4cxzkg3hx1li8yb3y79bp3npg2bffph-androidsdk/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/android/log.h", O_RDONLY|O_CLOEXEC <unfinished ...>
4185 openat(AT_FDCWD, "/nix/store/w4cxzkg3hx1li8yb3y79bp3npg2bffph-androidsdk/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/android/log.h", O_RDONLY|O_CLOEXEC <unfinished ...>
5623 openat(AT_FDCWD, "/nix/store/w4cxzkg3hx1li8yb3y79bp3npg2bffph-androidsdk/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/android/log.h", O_RDONLY|O_CLOEXEC <unfinished ...>
But I can't tell what's the difference. Both have ANDROID_HOME
set and provided.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputAndroid 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).
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: