First there is an issue with pthread that I can get past, but then it seems to struggle linking with symbol conflicts. I know sqlite and go both work on android, so i'm not sure why there is symbol duplication here.
example
// github.com/mattn/go-sqlite3/example2/test.go
package example2
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
var (
db *sql.DB
)
func OpenDatabase(filePath string) error {
d, err := sql.Open("sqlite3", filePath)
if err != nil {
return err
}
db = d
return nil
}
Trying to bind without any patches
}{mhawkins:~/Library/go/src/github.com/mattn/go-sqlite3/example2}{gomobile bind }{master!}{
# github.com/mattn/go-sqlite3
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lpthread
collect2: error: ld returned 1 exit status
gomobile: exit status 2
Making this change (turning off pthread for android, as the link is not required)
diff --git a/sqlite3_other.go b/sqlite3_other.go
index 8d98b4a..5c96d59 100644
--- a/sqlite3_other.go
+++ b/sqlite3_other.go
@@ -9,6 +9,6 @@ package sqlite3
/*
#cgo CFLAGS: -I.
#cgo linux LDFLAGS: -ldl
-#cgo LDFLAGS: -lpthread
+#cgo linux,-android LDFLAGS: -lpthread
*/
import "C"
Gets me past the android link issue. Now i'm having symbol conflicts, though
}{mhawkins:~/Library/go/src/github.com/mattn/go-sqlite3/example2}{gomobile bind }{master!}{
# command-line-arguments
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/5l: running /Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/arm-linux-androideabi-gcc failed: exit status 1
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000004.o: multiple definition of '__aeabi_uidivmod'
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000001.o: previous definition here
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000004.o: multiple definition of '__aeabi_uidiv'
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000001.o: previous definition here
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000004.o: multiple definition of '__udivsi3'
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000001.o: previous definition here
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000004.o: multiple definition of '__aeabi_unwind_cpp_pr0'
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000001.o: previous definition here
/Users/mhawkins/Library/go/pkg/gomobile/android-ndk-r10d/arm/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /var/folders/9s/_chc2vkd5l3d7251t9sflgk5759k1h/T/go-link-929937803/000004.o: multiple definition of '__gnu_Unwind_Restore_VFP_D'
...AND MANY MORE....
Any ideas? It seems it's a cgo link issue, but I'm not sure what it is.
First there is an issue with pthread that I can get past, but then it seems to struggle linking with symbol conflicts. I know sqlite and go both work on android, so i'm not sure why there is symbol duplication here.
example
Trying to bind without any patches
Making this change (turning off pthread for android, as the link is not required)
Gets me past the android link issue. Now i'm having symbol conflicts, though
Any ideas? It seems it's a cgo link issue, but I'm not sure what it is.