Issue
I'm trying to make an android executable (not APK) with C bindings in Go. Here are my variables:
set GOARCH=arm
set GOOS=linux
set CGO_ENABLED=1
set CC=C:\ndk\bin\arm-linux-androideabi-gcc
set CGO_LDFLAGS=-s -fPIE -pie -rdynamic -Wall -lstdc++ -lbinder -lutils -landroid_runtime -Lbin -linvoke
go build main.go
However when I tried to compile it with the settings above, it gives me:
# runtime/cgo
c:/ndk/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lpthread
collect2.exe: error: ld returned 1 exit status
After reading a bit about pthread
on android, it says that pthread
lib does not exists in android. How to overcome this? Thanks.
Solution
Android does not have a libpthread
, but the libc
contains a partial pthread implementation. You can use GOOS=android
to build the application with the correct ld
flags.
Answered By - JimB
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.