Hi,

I think I am skipping something obvious - but I really can't understand 
what. I looked both in Github and in golang-nuts for information.

I want to make a CLI app in Go to run in Android's Termux. I have Android 
NDK's installed and configured.

When I run:
```
CC="${GOPATH}/android-ndk/bin/arm-linux-androideabi-gcc" CGO_ENABLED=0 
GOOS=linux GOARCH=arm GOARM=7 go build
```

It compiles fine, but DNS does not work.

When I run: 
```
CC="${GOPATH}/android-ndk/bin/arm-linux-androideabi-gcc" GOOS=linux 
GOARCH=arm GOARM=7 go build
```

It compiles fine, but DNS does not work too.

It fails when I run:
```
CC="${GOPATH}/android-ndk/bin/arm-linux-androideabi-gcc" GOOS=android 
GOARCH=arm GOARM=7 go build
# github.com/ucirello/android-test
warning: unable to find runtime/cgo.a
```

Even worse, when I run: 
```
CC="${GOPATH}/android-ndk/bin/arm-linux-androideabi-gcc" GOOS=android  go 
build
...
arm-linux-androideabi-gcc: error: unrecognized command line option '-m64'
```

Finally, when I check Termux's own go package, I see:
```
$ go version
go version go1.9 android/arm64 
```

The application I am running is pretty simple: it only makes a simple HTTP 
Get call.
```
package main

import (
"fmt"
"io/ioutil"
"log"
"net/http"
)

func main() {
resp, err := http.Get("http://freegeoip.net/?q=67.161.33.142";)
if err != nil {
log.Fatal(err)
}
b, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(b))
}
```

The error I get is that it can't talk to the DNS server at [:::]:53 - which 
makes sense, because there is not a DNS server running locally.


It seems that GOOS=android will configure itself internally to use CGO, 
whereas GOOS=linux might end up using `/etc/resolv.conf` which is not 
present in the Termux's sandbox. So the question really is how do I get a 
GOOS=android build? The CC variable is there, and it seems correct.

Any suggestions?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to