Hello,
- bundling the sqlite3 concatenated sources (sqlite3-amalgamation-sources) and using CGO to compile them.
What I would like to do, and where I would like your opinions/tips, which approach is the most feasible:
- Using sqlite3 + the libspatialite extension.
This could be done in several ways/approaches I could think of. Each one contains a description, where I fail:
1. Use a sqlite Extension:
github.com/mattn-go-sqlite3 has support for loading sqlite3 extensions. I could just crosscompile a libspatilite.so library and load it.
My problem here: How can I bundle additional files (libspatialite.so) along my other code using the gomobile bind toolchain? Can I create a fat binary which contains my compiled Go code + libspatilite.so? Or Can I change my LD_LIBRARY_PATH on the Android device?
My problem here: How do I properly link a static library in CGO using the gomobile tool, meaning that it will also be in the generated Android aar?
Assume my library is in a directory "libs/android/armeabi": If I put the following cgo command in my code: #cgo LDFLAGS: -L${SRCDIR}/libs/android/armeabi -lspatialite I can build my project successfully, but the library is dynamically linked. Prepending -static -lspatialite does not help.
Passing the linker flags directory to the compiler CC using -ldflags "-linkmode external -extldflags=-static" or -ldflags "-extldflags=-static" does not help either, since now it tries to statically link also the Android runtime.
So what I would like to do: statically link my compiled C code the Go code. And after that use gomoble bind to create an Android aar.
My problem here: How do I make sure that Proj.4 and libgeos are built before libspatilite? Since they depend on each other? Could I use pkg-config for each library and make pkg-config depend on another pkg-config?
My preferred way would be variant 2 or 3, but I do not know how I can tell the compiler to statically link my libspatilite binary into my Go code and ship it along into the aar generated by gomobile bind. The aar just contains a binary of the Go runtime + my Go code, but without the libspatilite code. Using variant 1, the compiled c code is properly included in the aar.
Thank you for your help/suggestions.
Jan