6

I'm attempting to build a copy of sqlite with spatialite extensions. I've seen the one or two related posts online related to this issue, but no one seems to have gone all the way.

I've downloaded the spatialite amalgamation, GEOS and PROJ sources. I've created empty Android projects and moved the uncompressed files into the jni/ directory. The wall I'm running into now is creating the jni/Android.mk file. Does anyone have an example for the GEOS or PROJ dependencies? Has anyone been able to work through this process since the last stackexchange question linked to above?

Community
  • 1
  • 1
magneticMonster
  • 2,373
  • 6
  • 30
  • 46
  • I just happened upon this question while searching for prior work in this area. Since I've found nothing done yet, I am about to embark on this task myself. I'll post updates here if I make useful progress! – Mark Renouf Mar 13 '11 at 22:23

4 Answers4

6

I've set things up to compile spatialite as a shared library, and geos and proj as static libs (statically linked with spatialite). These also need libiconv (AFAIK) since the NDK libc doesn't provide iconv.h.

Fortunately, all of these are LGPL or compatible, so it's safe to include these in your app without fear of license issues.

NOTE: You need to run a './configure' first, inside both libiconv and libspatialite in order to generate headers. This requires 'autoconf' be installed.

Also note, this is on Linux (Ubuntu 10.10).

GEOS can't be built and linked in right now because C++ support for STL is completely missing in the NDK. If anyone can come up with a solution to building GEOS, let us know! I'm not sure how critical it is to have the advanced functions in GEOS, but it saves over 1MB of library size leaving it out according to the README.

Here's my main 'jni/Android.mk'. It could be split up into multiple files but I didn't bother cause I'm lazy :-)

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := iconv
LOCAL_CFLAGS    := \
    -Wno-multichar \
    -D_ANDROID \
    -DLIBDIR="\"c\"" \
    -DBUILDING_LIBICONV \
    -DIN_LIBRARY
LOCAL_C_INCLUDES := \
    libiconv-1.13.1 \
    libiconv-1.13.1/include \
    libiconv-1.13.1/lib \
    libiconv-1.13.1/libcharset/include
LOCAL_SRC_FILES := \
    libiconv-1.13.1/lib/iconv.c \
    libiconv-1.13.1/lib/relocatable.c \
    libiconv-1.13.1/libcharset/lib/localcharset.c
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := proj
LOCAL_C_INCLUDES := proj-4.7.0/src
LOCAL_LDLIBS := -lm
# this list was generated with:
#   find proj-4.7.0/ -name "*.c" | grep -Ev "tests|doc" | sort | awk '{ print "\t"$1" \\" }'
LOCAL_SRC_FILES := \
    proj-4.7.0/src/aasincos.c \
    proj-4.7.0/src/adjlon.c \
    proj-4.7.0/src/bch2bps.c \
    proj-4.7.0/src/bchgen.c \
    proj-4.7.0/src/biveval.c \
    proj-4.7.0/src/cs2cs.c \
    proj-4.7.0/src/dmstor.c \
    proj-4.7.0/src/emess.c \
    proj-4.7.0/src/gen_cheb.c \
    proj-4.7.0/src/geocent.c \
    proj-4.7.0/src/geod.c \
    proj-4.7.0/src/geod_for.c \
    proj-4.7.0/src/geod_inv.c \
    proj-4.7.0/src/geod_set.c \
    proj-4.7.0/src/jniproj.c \
    proj-4.7.0/src/mk_cheby.c \
    proj-4.7.0/src/nad2bin.c \
    proj-4.7.0/src/nad2nad.c \
    proj-4.7.0/src/nad_cvt.c \
    proj-4.7.0/src/nad_init.c \
    proj-4.7.0/src/nad_intr.c \
    proj-4.7.0/src/PJ_aea.c \
    proj-4.7.0/src/PJ_aeqd.c \
    proj-4.7.0/src/PJ_airy.c \
    proj-4.7.0/src/PJ_aitoff.c \
    proj-4.7.0/src/pj_apply_gridshift.c \
    proj-4.7.0/src/PJ_august.c \
    proj-4.7.0/src/pj_auth.c \
    proj-4.7.0/src/PJ_bacon.c \
    proj-4.7.0/src/PJ_bipc.c \
    proj-4.7.0/src/PJ_boggs.c \
    proj-4.7.0/src/PJ_bonne.c \
    proj-4.7.0/src/PJ_cass.c \
    proj-4.7.0/src/PJ_cc.c \
    proj-4.7.0/src/PJ_cea.c \
    proj-4.7.0/src/PJ_chamb.c \
    proj-4.7.0/src/PJ_collg.c \
    proj-4.7.0/src/PJ_crast.c \
    proj-4.7.0/src/pj_datums.c \
    proj-4.7.0/src/pj_datum_set.c \
    proj-4.7.0/src/PJ_denoy.c \
    proj-4.7.0/src/pj_deriv.c \
    proj-4.7.0/src/PJ_eck1.c \
    proj-4.7.0/src/PJ_eck2.c \
    proj-4.7.0/src/PJ_eck3.c \
    proj-4.7.0/src/PJ_eck4.c \
    proj-4.7.0/src/PJ_eck5.c \
    proj-4.7.0/src/pj_ellps.c \
    proj-4.7.0/src/pj_ell_set.c \
    proj-4.7.0/src/PJ_eqc.c \
    proj-4.7.0/src/PJ_eqdc.c \
    proj-4.7.0/src/pj_errno.c \
    proj-4.7.0/src/pj_factors.c \
    proj-4.7.0/src/PJ_fahey.c \
    proj-4.7.0/src/PJ_fouc_s.c \
    proj-4.7.0/src/pj_fwd.c \
    proj-4.7.0/src/PJ_gall.c \
    proj-4.7.0/src/pj_gauss.c \
    proj-4.7.0/src/pj_geocent.c \
    proj-4.7.0/src/PJ_geos.c \
    proj-4.7.0/src/PJ_gins8.c \
    proj-4.7.0/src/PJ_gnom.c \
    proj-4.7.0/src/PJ_gn_sinu.c \
    proj-4.7.0/src/PJ_goode.c \
    proj-4.7.0/src/pj_gridinfo.c \
    proj-4.7.0/src/pj_gridlist.c \
    proj-4.7.0/src/PJ_gstmerc.c \
    proj-4.7.0/src/PJ_hammer.c \
    proj-4.7.0/src/PJ_hatano.c \
    proj-4.7.0/src/PJ_imw_p.c \
    proj-4.7.0/src/pj_init.c \
    proj-4.7.0/src/pj_initcache.c \
    proj-4.7.0/src/pj_inv.c \
    proj-4.7.0/src/PJ_krovak.c \
    proj-4.7.0/src/PJ_labrd.c \
    proj-4.7.0/src/PJ_laea.c \
    proj-4.7.0/src/PJ_lagrng.c \
    proj-4.7.0/src/PJ_larr.c \
    proj-4.7.0/src/PJ_lask.c \
    proj-4.7.0/src/pj_latlong.c \
    proj-4.7.0/src/PJ_lcca.c \
    proj-4.7.0/src/PJ_lcc.c \
    proj-4.7.0/src/pj_list.c \
    proj-4.7.0/src/PJ_loxim.c \
    proj-4.7.0/src/PJ_lsat.c \
    proj-4.7.0/src/pj_malloc.c \
    proj-4.7.0/src/PJ_mbtfpp.c \
    proj-4.7.0/src/PJ_mbtfpq.c \
    proj-4.7.0/src/PJ_mbt_fps.c \
    proj-4.7.0/src/PJ_merc.c \
    proj-4.7.0/src/PJ_mill.c \
    proj-4.7.0/src/pj_mlfn.c \
    proj-4.7.0/src/PJ_mod_ster.c \
    proj-4.7.0/src/PJ_moll.c \
    proj-4.7.0/src/pj_msfn.c \
    proj-4.7.0/src/pj_mutex.c \
    proj-4.7.0/src/PJ_nell.c \
    proj-4.7.0/src/PJ_nell_h.c \
    proj-4.7.0/src/PJ_nocol.c \
    proj-4.7.0/src/PJ_nsper.c \
    proj-4.7.0/src/PJ_nzmg.c \
    proj-4.7.0/src/PJ_ob_tran.c \
    proj-4.7.0/src/PJ_ocea.c \
    proj-4.7.0/src/PJ_oea.c \
    proj-4.7.0/src/PJ_omerc.c \
    proj-4.7.0/src/pj_open_lib.c \
    proj-4.7.0/src/PJ_ortho.c \
    proj-4.7.0/src/pj_param.c \
    proj-4.7.0/src/pj_phi2.c \
    proj-4.7.0/src/PJ_poly.c \
    proj-4.7.0/src/pj_pr_list.c \
    proj-4.7.0/src/PJ_putp2.c \
    proj-4.7.0/src/PJ_putp3.c \
    proj-4.7.0/src/PJ_putp4p.c \
    proj-4.7.0/src/PJ_putp5.c \
    proj-4.7.0/src/PJ_putp6.c \
    proj-4.7.0/src/pj_qsfn.c \
    proj-4.7.0/src/pj_release.c \
    proj-4.7.0/src/PJ_robin.c \
    proj-4.7.0/src/PJ_rpoly.c \
    proj-4.7.0/src/PJ_sconics.c \
    proj-4.7.0/src/PJ_somerc.c \
    proj-4.7.0/src/PJ_sterea.c \
    proj-4.7.0/src/PJ_stere.c \
    proj-4.7.0/src/pj_strerrno.c \
    proj-4.7.0/src/PJ_sts.c \
    proj-4.7.0/src/PJ_tcc.c \
    proj-4.7.0/src/PJ_tcea.c \
    proj-4.7.0/src/PJ_tmerc.c \
    proj-4.7.0/src/PJ_tpeqd.c \
    proj-4.7.0/src/pj_transform.c \
    proj-4.7.0/src/pj_tsfn.c \
    proj-4.7.0/src/pj_units.c \
    proj-4.7.0/src/PJ_urm5.c \
    proj-4.7.0/src/PJ_urmfps.c \
    proj-4.7.0/src/pj_utils.c \
    proj-4.7.0/src/PJ_vandg2.c \
    proj-4.7.0/src/PJ_vandg4.c \
    proj-4.7.0/src/PJ_vandg.c \
    proj-4.7.0/src/PJ_wag2.c \
    proj-4.7.0/src/PJ_wag3.c \
    proj-4.7.0/src/PJ_wag7.c \
    proj-4.7.0/src/PJ_wink1.c \
    proj-4.7.0/src/PJ_wink2.c \
    proj-4.7.0/src/pj_zpoly1.c \
    proj-4.7.0/src/proj.c \
    proj-4.7.0/src/proj_mdist.c \
    proj-4.7.0/src/proj_rouss.c \
    proj-4.7.0/src/p_series.c \
    proj-4.7.0/src/rtodms.c \
    proj-4.7.0/src/vector1.c
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := spatialite
LOCAL_CFLAGS    := -D__ANDROID__ -DOMIT_GEOS=1 -Dfdatasync=fsync
LOCAL_C_INCLUDES := \
    libiconv-1.13.1/include \
    libiconv-1.13.1/libcharset/include \
    geos-3.2.2/source/headers \
    geos-3.2.2/capi \
    proj-4.7.0/src
LOCAL_SRC_FILES := \
    ./libspatialite-amalgamation-2.3.1/spatialite.c \
    ./libspatialite-amalgamation-2.3.1/sqlite3.c
LOCAL_STATIC_LIBRARIES := iconv proj
include $(BUILD_SHARED_LIBRARY)

With this you'll need to apply some small patches to the sources to get things pulling in the right headers. The Mac build was close but using -D_APPLE_ caused some other weirdness. I ended up just patching up the parts of libiconv and spatialite that I needed to:

diff --git a/android/jni/libiconv-1.13.1/libcharset/lib/localcharset.c b/android/jni/libiconv-1.13.1/libcharset/lib/localcharset.c
index 434fc7c..44b087d 100644
--- a/android/jni/libiconv-1.13.1/libcharset/lib/localcharset.c
+++ b/android/jni/libiconv-1.13.1/libcharset/lib/localcharset.c
@@ -44,7 +44,7 @@
 # endif
 #endif

-#if !defined WIN32_NATIVE
+#if !defined(WIN32_NATIVE) && !defined(__ANDROID__)
 # if HAVE_LANGINFO_CODESET
 #  include <langinfo.h>
 # else
@@ -328,7 +328,7 @@ locale_charset (void)
   const char *codeset;
   const char *aliases;

-#if !(defined WIN32_NATIVE || defined OS2)
+#if !(defined WIN32_NATIVE || defined OS2 || defined __ANDROID__)

 # if HAVE_LANGINFO_CODESET

diff --git a/android/jni/libspatialite-amalgamation-2.3.1/spatialite.c b/android/jni/libspatialite-amalgamation-2.3.1/spatialite.c
index 5fed6f0..d482ecc 100644
--- a/android/jni/libspatialite-amalgamation-2.3.1/spatialite.c
+++ b/android/jni/libspatialite-amalgamation-2.3.1/spatialite.c
@@ -72,7 +72,7 @@ extern const char * locale_charset (void);
 #include <localcharset.h>
 #endif /* end localcharset */
 #else /* not WINDOWS */
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
 #include <iconv.h>
 #include <localcharset.h>
 #else /* not Mac OsX */
@@ -7508,7 +7508,7 @@ gaiaCleanSqlString (char *value)
 #define LIBCHARSET_STATIC
 /* #include <localcharset.h> */
 #else /* not MINGW32 - WIN32 */
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
 /* #include <iconv.h> */
 /* #include <localcharset.h> */
 #else /* not Mac OsX */
@@ -7526,7 +7526,7 @@ gaiaGetLocaleCharset ()
 #if defined(__MINGW32__) || defined(_WIN32)
     return locale_charset ();
 #else /* not MINGW32 - WIN32 */
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
     return locale_charset ();
 #else /* not Mac OsX */
     return nl_langinfo (CODESET);
@@ -13896,7 +13896,7 @@ gaiaPolygonize (gaiaGeomCollPtr geom_org, int force_multipolygon)
 #define LIBCHARSET_STATIC
 /* #include <localcharset.h> */
 #else /* not MINGW32 */
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
 /* #include <iconv.h> */
 /* #include <localcharset.h> */
 #else /* not Mac OsX */

And here's the output:

mark@beast:~/Code/android-spatialite/jni$ ndk-build 
Compile thumb  : spatialite <= spatialite.c
Compile thumb  : spatialite <= sqlite3.c
/home/mark/Code/android-spatialite/jni/./libspatialite-amalgamation-2.3.1/sqlite3.c: In function 'unixDlError':
/home/mark/Code/android-spatialite/jni/./libspatialite-amalgamation-2.3.1/sqlite3.c:24986: warning: assignment discards qualifiers from pointer target type
Compile thumb  : iconv <= iconv.c
Compile thumb  : iconv <= relocatable.c
Compile thumb  : iconv <= localcharset.c
StaticLibrary  : libiconv.a
Compile thumb  : proj <= aasincos.c
Compile thumb  : proj <= adjlon.c
Compile thumb  : proj <= bch2bps.c
Compile thumb  : proj <= bchgen.c
Compile thumb  : proj <= biveval.c
Compile thumb  : proj <= cs2cs.c
Compile thumb  : proj <= dmstor.c
Compile thumb  : proj <= emess.c
Compile thumb  : proj <= gen_cheb.c
Compile thumb  : proj <= geocent.c
Compile thumb  : proj <= geod.c
Compile thumb  : proj <= geod_for.c
Compile thumb  : proj <= geod_inv.c
Compile thumb  : proj <= geod_set.c
Compile thumb  : proj <= jniproj.c
Compile thumb  : proj <= mk_cheby.c
Compile thumb  : proj <= nad2bin.c
Compile thumb  : proj <= nad2nad.c
Compile thumb  : proj <= nad_cvt.c
Compile thumb  : proj <= nad_init.c
Compile thumb  : proj <= nad_intr.c
Compile thumb  : proj <= PJ_aea.c
Compile thumb  : proj <= PJ_aeqd.c
Compile thumb  : proj <= PJ_airy.c
Compile thumb  : proj <= PJ_aitoff.c
Compile thumb  : proj <= pj_apply_gridshift.c
Compile thumb  : proj <= PJ_august.c
Compile thumb  : proj <= pj_auth.c
Compile thumb  : proj <= PJ_bacon.c
Compile thumb  : proj <= PJ_bipc.c
Compile thumb  : proj <= PJ_boggs.c
Compile thumb  : proj <= PJ_bonne.c
Compile thumb  : proj <= PJ_cass.c
Compile thumb  : proj <= PJ_cc.c
Compile thumb  : proj <= PJ_cea.c
Compile thumb  : proj <= PJ_chamb.c
Compile thumb  : proj <= PJ_collg.c
Compile thumb  : proj <= PJ_crast.c
Compile thumb  : proj <= pj_datums.c
Compile thumb  : proj <= pj_datum_set.c
Compile thumb  : proj <= PJ_denoy.c
Compile thumb  : proj <= pj_deriv.c
Compile thumb  : proj <= PJ_eck1.c
Compile thumb  : proj <= PJ_eck2.c
Compile thumb  : proj <= PJ_eck3.c
Compile thumb  : proj <= PJ_eck4.c
Compile thumb  : proj <= PJ_eck5.c
Compile thumb  : proj <= pj_ellps.c
Compile thumb  : proj <= pj_ell_set.c
Compile thumb  : proj <= PJ_eqc.c
Compile thumb  : proj <= PJ_eqdc.c
Compile thumb  : proj <= pj_errno.c
Compile thumb  : proj <= pj_factors.c
Compile thumb  : proj <= PJ_fahey.c
Compile thumb  : proj <= PJ_fouc_s.c
Compile thumb  : proj <= pj_fwd.c
Compile thumb  : proj <= PJ_gall.c
Compile thumb  : proj <= pj_gauss.c
Compile thumb  : proj <= pj_geocent.c
Compile thumb  : proj <= PJ_geos.c
Compile thumb  : proj <= PJ_gins8.c
Compile thumb  : proj <= PJ_gnom.c
Compile thumb  : proj <= PJ_gn_sinu.c
Compile thumb  : proj <= PJ_goode.c
Compile thumb  : proj <= pj_gridinfo.c
Compile thumb  : proj <= pj_gridlist.c
Compile thumb  : proj <= PJ_gstmerc.c
Compile thumb  : proj <= PJ_hammer.c
Compile thumb  : proj <= PJ_hatano.c
Compile thumb  : proj <= PJ_imw_p.c
Compile thumb  : proj <= pj_init.c
Compile thumb  : proj <= pj_initcache.c
Compile thumb  : proj <= pj_inv.c
Compile thumb  : proj <= PJ_krovak.c
Compile thumb  : proj <= PJ_labrd.c
Compile thumb  : proj <= PJ_laea.c
Compile thumb  : proj <= PJ_lagrng.c
Compile thumb  : proj <= PJ_larr.c
Compile thumb  : proj <= PJ_lask.c
Compile thumb  : proj <= pj_latlong.c
Compile thumb  : proj <= PJ_lcca.c
Compile thumb  : proj <= PJ_lcc.c
Compile thumb  : proj <= pj_list.c
Compile thumb  : proj <= PJ_loxim.c
Compile thumb  : proj <= PJ_lsat.c
Compile thumb  : proj <= pj_malloc.c
Compile thumb  : proj <= PJ_mbtfpp.c
Compile thumb  : proj <= PJ_mbtfpq.c
Compile thumb  : proj <= PJ_mbt_fps.c
Compile thumb  : proj <= PJ_merc.c
Compile thumb  : proj <= PJ_mill.c
Compile thumb  : proj <= pj_mlfn.c
Compile thumb  : proj <= PJ_mod_ster.c
Compile thumb  : proj <= PJ_moll.c
Compile thumb  : proj <= pj_msfn.c
Compile thumb  : proj <= pj_mutex.c
Compile thumb  : proj <= PJ_nell.c
Compile thumb  : proj <= PJ_nell_h.c
Compile thumb  : proj <= PJ_nocol.c
Compile thumb  : proj <= PJ_nsper.c
Compile thumb  : proj <= PJ_nzmg.c
Compile thumb  : proj <= PJ_ob_tran.c
Compile thumb  : proj <= PJ_ocea.c
Compile thumb  : proj <= PJ_oea.c
Compile thumb  : proj <= PJ_omerc.c
Compile thumb  : proj <= pj_open_lib.c
Compile thumb  : proj <= PJ_ortho.c
Compile thumb  : proj <= pj_param.c
Compile thumb  : proj <= pj_phi2.c
Compile thumb  : proj <= PJ_poly.c
Compile thumb  : proj <= pj_pr_list.c
Compile thumb  : proj <= PJ_putp2.c
Compile thumb  : proj <= PJ_putp3.c
Compile thumb  : proj <= PJ_putp4p.c
Compile thumb  : proj <= PJ_putp5.c
Compile thumb  : proj <= PJ_putp6.c
Compile thumb  : proj <= pj_qsfn.c
Compile thumb  : proj <= pj_release.c
Compile thumb  : proj <= PJ_robin.c
Compile thumb  : proj <= PJ_rpoly.c
Compile thumb  : proj <= PJ_sconics.c
Compile thumb  : proj <= PJ_somerc.c
Compile thumb  : proj <= PJ_sterea.c
Compile thumb  : proj <= PJ_stere.c
Compile thumb  : proj <= pj_strerrno.c
Compile thumb  : proj <= PJ_sts.c
Compile thumb  : proj <= PJ_tcc.c
Compile thumb  : proj <= PJ_tcea.c
Compile thumb  : proj <= PJ_tmerc.c
Compile thumb  : proj <= PJ_tpeqd.c
Compile thumb  : proj <= pj_transform.c
Compile thumb  : proj <= pj_tsfn.c
Compile thumb  : proj <= pj_units.c
Compile thumb  : proj <= PJ_urm5.c
Compile thumb  : proj <= PJ_urmfps.c
Compile thumb  : proj <= pj_utils.c
Compile thumb  : proj <= PJ_vandg2.c
Compile thumb  : proj <= PJ_vandg4.c
Compile thumb  : proj <= PJ_vandg.c
Compile thumb  : proj <= PJ_wag2.c
Compile thumb  : proj <= PJ_wag3.c
Compile thumb  : proj <= PJ_wag7.c
Compile thumb  : proj <= PJ_wink1.c
Compile thumb  : proj <= PJ_wink2.c
Compile thumb  : proj <= pj_zpoly1.c
Compile thumb  : proj <= proj.c
Compile thumb  : proj <= proj_mdist.c
Compile thumb  : proj <= proj_rouss.c
Compile thumb  : proj <= p_series.c
Compile thumb  : proj <= rtodms.c
Compile thumb  : proj <= vector1.c
StaticLibrary  : libproj.a
SharedLibrary  : libspatialite.so
Install        : libspatialite.so => libs/armeabi/libspatialite.so

The resulting library:

$ ls -l ../libs/armeabi/libspatialite.so 
-rwxr-xr-x 1 mark mark 1560744 2011-03-13 22:23 ../libs/armeabi/libspatialite.so
Mark Renouf
  • 30,697
  • 19
  • 94
  • 123
  • I created a GitHub project to make it a bit easier for others to test this. https://github.com/mrenouf/android-spatialite – Mark Renouf Mar 14 '11 at 03:17
  • Wow, thanks for working on this! I've spent the last 48 hours looking into this and got as far as getting libspatialite.so compiled and running in an activity, but it would SIGSEGV whenever I tried to use spatialite functions in sqlite. I'll try this and let you know! – magneticMonster Mar 14 '11 at 04:03
  • I've seen references to some "hacks" needed to enable extension loading, but nobody has documented these. AFAIK extension loading is off by default on Android, right? – Mark Renouf Mar 14 '11 at 11:23
  • Yes. I had to compile my own libsqlite3.so library and jsqlite classes. Can you tell me what environment variables or arguments you gave to ./configure for proj4, iconv, and spatialite? – magneticMonster Mar 14 '11 at 12:25
  • None. I suspect that may be the cause of some issues? Though the generated Makefiles are not actually used. All of the CFLAGS and LDFLAGS are specified in Android.mk. – Mark Renouf Mar 14 '11 at 12:35
  • I added a full Android project structure to my GitHub repo, could you provide the Java side of this and the JNI stubs to build? Also, I was under the impresstion that spatialite now contains a complete standalone sqlite implementation, in addition to being usable as an extension. Is it possible to just link against it, and leave out jsqlite? I'm thinking the library could be used with sources take from AOSP just substituting libspatialite im place of sqlite? – Mark Renouf Mar 14 '11 at 12:38
  • When I was poking around it looked like ./configure set up some header files that were used in the ndk-build process. I'm wondering if having those generated with your development system (instead of Android) as the target will break it. Will give it a try, though! – magneticMonster Mar 14 '11 at 12:38
  • Re: AOSP -- https://github.com/android/platform_frameworks_base/tree/master/core/java/android/database/sqlite AND https://github.com/android/platform_frameworks_base/blob/master/core/jni/android_database_SQLiteDatabase.cpp etc... – Mark Renouf Mar 14 '11 at 12:47
  • Nevermind, I see now how everything is compiled into one monolithic android_runtime library and loaded before an app is ever started, which makes it impossible to replace the native impl of anything in android.* code. – Mark Renouf Mar 14 '11 at 12:59
  • FYI, I'm also looking into http://code.google.com/p/sqlite4java/ (home on a sickday so I get some time to hack a bit ;-)) – Mark Renouf Mar 14 '11 at 13:20
  • Looks like I'm getting a SIGSEGV again. See the fork on your github project for the code I added to get it to run in an activity. – magneticMonster Mar 14 '11 at 14:50
  • AH! I take that back! I got it running. I had to explicitly import the libspatialite.so as an SQL command. – magneticMonster Mar 14 '11 at 14:52
  • Isn't it violate LGPL to link statically one LGPL library (libiconv) to other LGPL library (spatialite) ? – triclosan Aug 03 '16 at 13:45
1

So I noticed there were some issues with Spatialite 2.3.1 and GEOS 3.1.1. The following query always returned 0.0 for some reason.

select Distance(geomfromtext('point(60 60)', 4326), geomfromtext('point(59 60)', 4326));

Anyways, I retrieved Spatialite 2.4.0 RC4, GEOS 3.2.2, iconv 1.13.1, proj 4.6.1 and applied the code changes to iconv and Spatialite. I was able to successfully compile and run the code on Android 2.2 with the following Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
LOCAL_MODULE := iconv
LOCAL_CFLAGS := \
    -Wno-multichar \
    -D_ANDROID \
    -DBUILDING_LIBICONV \
    -DIN_LIBRARY \
    -DLIBDIR="\"/usr/local/android-libs/usr/local/lib\"" 
LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/libiconv-1.13.1 \
    $(LOCAL_PATH)/libiconv-1.13.1/include \
    $(LOCAL_PATH)/libiconv-1.13.1/lib \
    $(LOCAL_PATH)/libiconv-1.13.1/libcharset/include
LOCAL_SRC_FILES := \
    libiconv-1.13.1/lib/iconv.c \
    libiconv-1.13.1/lib/relocatable.c \
    libiconv-1.13.1/lib/empty.cpp \
    libiconv-1.13.1/libcharset/lib/localcharset.c
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
# find proj-4.6.1/ -name "*.c" | grep -Ev "tests|doc" | sort | awk '{ print "\t"$1" \\" }'
LOCAL_MODULE    := proj
LOCAL_C_INCLUDES := $(LOCAL_PATH)/proj-4.6.1/src
LOCAL_LDLIBS := -lm
LOCAL_SRC_FILES := \
    proj-4.6.1/src/empty.cpp \
    proj-4.6.1/src/aasincos.c \
    proj-4.6.1/src/adjlon.c \
    proj-4.6.1/src/bch2bps.c \
    proj-4.6.1/src/bchgen.c \
    proj-4.6.1/src/biveval.c \
    proj-4.6.1/src/dmstor.c \
    proj-4.6.1/src/emess.c \
    proj-4.6.1/src/gen_cheb.c \
    proj-4.6.1/src/geocent.c \
    proj-4.6.1/src/geod_for.c \
    proj-4.6.1/src/geod_inv.c \
    proj-4.6.1/src/geod_set.c \
    proj-4.6.1/src/jniproj.c \
    proj-4.6.1/src/mk_cheby.c \
    proj-4.6.1/src/nad_cvt.c \
    proj-4.6.1/src/nad_init.c \
    proj-4.6.1/src/nad_intr.c \
    proj-4.6.1/src/PJ_aea.c \
    proj-4.6.1/src/PJ_aeqd.c \
    proj-4.6.1/src/PJ_airy.c \
    proj-4.6.1/src/PJ_aitoff.c \
    proj-4.6.1/src/pj_apply_gridshift.c \
    proj-4.6.1/src/PJ_august.c \
    proj-4.6.1/src/pj_auth.c \
    proj-4.6.1/src/PJ_bacon.c \
    proj-4.6.1/src/PJ_bipc.c \
    proj-4.6.1/src/PJ_boggs.c \
    proj-4.6.1/src/PJ_bonne.c \
    proj-4.6.1/src/PJ_cass.c \
    proj-4.6.1/src/PJ_cc.c \
    proj-4.6.1/src/PJ_cea.c \
    proj-4.6.1/src/PJ_chamb.c \
    proj-4.6.1/src/PJ_collg.c \
    proj-4.6.1/src/PJ_crast.c \
    proj-4.6.1/src/pj_datums.c \
    proj-4.6.1/src/pj_datum_set.c \
    proj-4.6.1/src/PJ_denoy.c \
    proj-4.6.1/src/pj_deriv.c \
    proj-4.6.1/src/PJ_eck1.c \
    proj-4.6.1/src/PJ_eck2.c \
    proj-4.6.1/src/PJ_eck3.c \
    proj-4.6.1/src/PJ_eck4.c \
    proj-4.6.1/src/PJ_eck5.c \
    proj-4.6.1/src/pj_ellps.c \
    proj-4.6.1/src/pj_ell_set.c \
    proj-4.6.1/src/PJ_eqc.c \
    proj-4.6.1/src/PJ_eqdc.c \
    proj-4.6.1/src/pj_errno.c \
    proj-4.6.1/src/pj_factors.c \
    proj-4.6.1/src/PJ_fahey.c \
    proj-4.6.1/src/PJ_fouc_s.c \
    proj-4.6.1/src/pj_fwd.c \
    proj-4.6.1/src/PJ_gall.c \
    proj-4.6.1/src/pj_gauss.c \
    proj-4.6.1/src/pj_geocent.c \
    proj-4.6.1/src/PJ_geos.c \
    proj-4.6.1/src/PJ_gins8.c \
    proj-4.6.1/src/PJ_gnom.c \
    proj-4.6.1/src/PJ_gn_sinu.c \
    proj-4.6.1/src/PJ_goode.c \
    proj-4.6.1/src/pj_gridinfo.c \
    proj-4.6.1/src/pj_gridlist.c \
    proj-4.6.1/src/PJ_gstmerc.c \
    proj-4.6.1/src/PJ_hammer.c \
    proj-4.6.1/src/PJ_hatano.c \
    proj-4.6.1/src/PJ_imw_p.c \
    proj-4.6.1/src/pj_init.c \
    proj-4.6.1/src/pj_inv.c \
    proj-4.6.1/src/PJ_krovak.c \
    proj-4.6.1/src/PJ_labrd.c \
    proj-4.6.1/src/PJ_laea.c \
    proj-4.6.1/src/PJ_lagrng.c \
    proj-4.6.1/src/PJ_larr.c \
    proj-4.6.1/src/PJ_lask.c \
    proj-4.6.1/src/pj_latlong.c \
    proj-4.6.1/src/PJ_lcca.c \
    proj-4.6.1/src/PJ_lcc.c \
    proj-4.6.1/src/pj_list.c \
    proj-4.6.1/src/PJ_loxim.c \
    proj-4.6.1/src/PJ_lsat.c \
    proj-4.6.1/src/pj_malloc.c \
    proj-4.6.1/src/PJ_mbtfpp.c \
    proj-4.6.1/src/PJ_mbtfpq.c \
    proj-4.6.1/src/PJ_mbt_fps.c \
    proj-4.6.1/src/PJ_merc.c \
    proj-4.6.1/src/PJ_mill.c \
    proj-4.6.1/src/pj_mlfn.c \
    proj-4.6.1/src/PJ_mod_ster.c \
    proj-4.6.1/src/PJ_moll.c \
    proj-4.6.1/src/pj_msfn.c \
    proj-4.6.1/src/PJ_nell.c \
    proj-4.6.1/src/PJ_nell_h.c \
    proj-4.6.1/src/PJ_nocol.c \
    proj-4.6.1/src/PJ_nsper.c \
    proj-4.6.1/src/PJ_nzmg.c \
    proj-4.6.1/src/PJ_ob_tran.c \
    proj-4.6.1/src/PJ_ocea.c \
    proj-4.6.1/src/PJ_oea.c \
    proj-4.6.1/src/PJ_omerc.c \
    proj-4.6.1/src/pj_open_lib.c \
    proj-4.6.1/src/PJ_ortho.c \
    proj-4.6.1/src/pj_param.c \
    proj-4.6.1/src/pj_phi2.c \
    proj-4.6.1/src/PJ_poly.c \
    proj-4.6.1/src/pj_pr_list.c \
    proj-4.6.1/src/PJ_putp2.c \
    proj-4.6.1/src/PJ_putp3.c \
    proj-4.6.1/src/PJ_putp4p.c \
    proj-4.6.1/src/PJ_putp5.c \
    proj-4.6.1/src/PJ_putp6.c \
    proj-4.6.1/src/pj_qsfn.c \
    proj-4.6.1/src/pj_release.c \
    proj-4.6.1/src/PJ_robin.c \
    proj-4.6.1/src/PJ_rpoly.c \
    proj-4.6.1/src/PJ_sconics.c \
    proj-4.6.1/src/PJ_somerc.c \
    proj-4.6.1/src/PJ_sterea.c \
    proj-4.6.1/src/PJ_stere.c \
    proj-4.6.1/src/pj_strerrno.c \
    proj-4.6.1/src/PJ_sts.c \
    proj-4.6.1/src/PJ_tcc.c \
    proj-4.6.1/src/PJ_tcea.c \
    proj-4.6.1/src/PJ_tmerc.c \
    proj-4.6.1/src/PJ_tpeqd.c \
    proj-4.6.1/src/pj_transform.c \
    proj-4.6.1/src/pj_tsfn.c \
    proj-4.6.1/src/pj_units.c \
    proj-4.6.1/src/PJ_urm5.c \
    proj-4.6.1/src/PJ_urmfps.c \
    proj-4.6.1/src/pj_utils.c \
    proj-4.6.1/src/PJ_vandg2.c \
    proj-4.6.1/src/PJ_vandg4.c \
    proj-4.6.1/src/PJ_vandg.c \
    proj-4.6.1/src/PJ_wag2.c \
    proj-4.6.1/src/PJ_wag3.c \
    proj-4.6.1/src/PJ_wag7.c \
    proj-4.6.1/src/PJ_wink1.c \
    proj-4.6.1/src/PJ_wink2.c \
    proj-4.6.1/src/pj_zpoly1.c \
    proj-4.6.1/src/proj.c \
    proj-4.6.1/src/proj_mdist.c \
    proj-4.6.1/src/proj_rouss.c \
    proj-4.6.1/src/p_series.c \
    proj-4.6.1/src/rtodms.c \
    proj-4.6.1/src/vector1.c
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
# find geos-3.2.2/ -name "*.cpp" | grep -Ev "tests|doc" | sort | awk '{ print "\t"$1" \\" }'
LOCAL_MODULE := geos
LOCAL_C_INCLUDES := $(LOCAL_PATH)/geos-3.2.2/source/headers
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%)
LOCAL_SRC_FILES := \
    geos-3.2.2/capi/geos_c.cpp \
    geos-3.2.2/capi/geos_ts_c.cpp \
    geos-3.2.2/source/algorithm/Angle.cpp \
    geos-3.2.2/source/algorithm/BoundaryNodeRule.cpp \
    geos-3.2.2/source/algorithm/CentroidArea.cpp \
    geos-3.2.2/source/algorithm/CentroidLine.cpp \
    geos-3.2.2/source/algorithm/CentroidPoint.cpp \
    geos-3.2.2/source/algorithm/CGAlgorithms.cpp \
    geos-3.2.2/source/algorithm/ConvexHull.cpp \
    geos-3.2.2/source/algorithm/distance/DiscreteHausdorffDistance.cpp \
    geos-3.2.2/source/algorithm/distance/DistanceToPoint.cpp \
    geos-3.2.2/source/algorithm/HCoordinate.cpp \
    geos-3.2.2/source/algorithm/InteriorPointArea.cpp \
    geos-3.2.2/source/algorithm/InteriorPointLine.cpp \
    geos-3.2.2/source/algorithm/InteriorPointPoint.cpp \
    geos-3.2.2/source/algorithm/LineIntersector.cpp \
    geos-3.2.2/source/algorithm/locate/IndexedPointInAreaLocator.cpp \
    geos-3.2.2/source/algorithm/locate/PointOnGeometryLocator.cpp \
    geos-3.2.2/source/algorithm/locate/SimplePointInAreaLocator.cpp \
    geos-3.2.2/source/algorithm/MCPointInRing.cpp \
    geos-3.2.2/source/algorithm/MinimumDiameter.cpp \
    geos-3.2.2/source/algorithm/NotRepresentableException.cpp \
    geos-3.2.2/source/algorithm/PointLocator.cpp \
    geos-3.2.2/source/algorithm/RayCrossingCounter.cpp \
    geos-3.2.2/source/algorithm/RobustDeterminant.cpp \
    geos-3.2.2/source/algorithm/SimplePointInRing.cpp \
    geos-3.2.2/source/algorithm/SIRtreePointInRing.cpp \
    geos-3.2.2/source/geom/CoordinateArraySequence.cpp \
    geos-3.2.2/source/geom/CoordinateArraySequenceFactory.cpp \
    geos-3.2.2/source/geom/Coordinate.cpp \
    geos-3.2.2/source/geom/CoordinateSequence.cpp \
    geos-3.2.2/source/geom/CoordinateSequenceFactory.cpp \
    geos-3.2.2/source/geom/Dimension.cpp \
    geos-3.2.2/source/geom/Envelope.cpp \
    geos-3.2.2/source/geom/GeometryCollection.cpp \
    geos-3.2.2/source/geom/GeometryComponentFilter.cpp \
    geos-3.2.2/source/geom/Geometry.cpp \
    geos-3.2.2/source/geom/GeometryFactory.cpp \
    geos-3.2.2/source/geom/GeometryList.cpp \
    geos-3.2.2/source/geomgraph/Depth.cpp \
    geos-3.2.2/source/geomgraph/DirectedEdge.cpp \
    geos-3.2.2/source/geomgraph/DirectedEdgeStar.cpp \
    geos-3.2.2/source/geomgraph/Edge.cpp \
    geos-3.2.2/source/geomgraph/EdgeEnd.cpp \
    geos-3.2.2/source/geomgraph/EdgeEndStar.cpp \
    geos-3.2.2/source/geomgraph/EdgeIntersection.cpp \
    geos-3.2.2/source/geomgraph/EdgeIntersectionList.cpp \
    geos-3.2.2/source/geomgraph/EdgeList.cpp \
    geos-3.2.2/source/geomgraph/EdgeNodingValidator.cpp \
    geos-3.2.2/source/geomgraph/EdgeRing.cpp \
    geos-3.2.2/source/geomgraph/GeometryGraph.cpp \
    geos-3.2.2/source/geomgraph/GraphComponent.cpp \
    geos-3.2.2/source/geomgraph/index/MonotoneChainEdge.cpp \
    geos-3.2.2/source/geomgraph/index/MonotoneChainIndexer.cpp \
    geos-3.2.2/source/geomgraph/index/SegmentIntersector.cpp \
    geos-3.2.2/source/geomgraph/index/SimpleEdgeSetIntersector.cpp \
    geos-3.2.2/source/geomgraph/index/SimpleMCSweepLineIntersector.cpp \
    geos-3.2.2/source/geomgraph/index/SimpleSweepLineIntersector.cpp \
    geos-3.2.2/source/geomgraph/index/SweepLineEvent.cpp \
    geos-3.2.2/source/geomgraph/index/SweepLineSegment.cpp \
    geos-3.2.2/source/geomgraph/Label.cpp \
    geos-3.2.2/source/geomgraph/Node.cpp \
    geos-3.2.2/source/geomgraph/NodeFactory.cpp \
    geos-3.2.2/source/geomgraph/NodeMap.cpp \
    geos-3.2.2/source/geomgraph/PlanarGraph.cpp \
    geos-3.2.2/source/geomgraph/Position.cpp \
    geos-3.2.2/source/geomgraph/Quadrant.cpp \
    geos-3.2.2/source/geomgraph/TopologyLocation.cpp \
    geos-3.2.2/source/geom/IntersectionMatrix.cpp \
    geos-3.2.2/source/geom/LinearRing.cpp \
    geos-3.2.2/source/geom/LineSegment.cpp \
    geos-3.2.2/source/geom/LineString.cpp \
    geos-3.2.2/source/geom/Location.cpp \
    geos-3.2.2/source/geom/MultiLineString.cpp \
    geos-3.2.2/source/geom/MultiPoint.cpp \
    geos-3.2.2/source/geom/MultiPolygon.cpp \
    geos-3.2.2/source/geom/Point.cpp \
    geos-3.2.2/source/geom/Polygon.cpp \
    geos-3.2.2/source/geom/PrecisionModel.cpp \
    geos-3.2.2/source/geom/prep/AbstractPreparedPolygonContains.cpp \
    geos-3.2.2/source/geom/prep/BasicPreparedGeometry.cpp \
    geos-3.2.2/source/geom/prep/PreparedGeometry.cpp \
    geos-3.2.2/source/geom/prep/PreparedGeometryFactory.cpp \
    geos-3.2.2/source/geom/prep/PreparedLineString.cpp \
    geos-3.2.2/source/geom/prep/PreparedLineStringIntersects.cpp \
    geos-3.2.2/source/geom/prep/PreparedPoint.cpp \
    geos-3.2.2/source/geom/prep/PreparedPolygonContains.cpp \
    geos-3.2.2/source/geom/prep/PreparedPolygonContainsProperly.cpp \
    geos-3.2.2/source/geom/prep/PreparedPolygonCovers.cpp \
    geos-3.2.2/source/geom/prep/PreparedPolygon.cpp \
    geos-3.2.2/source/geom/prep/PreparedPolygonIntersects.cpp \
    geos-3.2.2/source/geom/prep/PreparedPolygonPredicate.cpp \
    geos-3.2.2/source/geom/Triangle.cpp \
    geos-3.2.2/source/geom/util/ComponentCoordinateExtracter.cpp \
    geos-3.2.2/source/geom/util/CoordinateOperation.cpp \
    geos-3.2.2/source/geom/util/GeometryCombiner.cpp \
    geos-3.2.2/source/geom/util/GeometryEditor.cpp \
    geos-3.2.2/source/geom/util/GeometryTransformer.cpp \
    geos-3.2.2/source/geom/util/ShortCircuitedGeometryVisitor.cpp \
    geos-3.2.2/source/index/bintree/Bintree.cpp \
    geos-3.2.2/source/index/bintree/Interval.cpp \
    geos-3.2.2/source/index/bintree/Key.cpp \
    geos-3.2.2/source/index/bintree/NodeBase.cpp \
    geos-3.2.2/source/index/bintree/Node.cpp \
    geos-3.2.2/source/index/bintree/Root.cpp \
    geos-3.2.2/source/index/chain/MonotoneChainBuilder.cpp \
    geos-3.2.2/source/index/chain/MonotoneChain.cpp \
    geos-3.2.2/source/index/chain/MonotoneChainOverlapAction.cpp \
    geos-3.2.2/source/index/chain/MonotoneChainSelectAction.cpp \
    geos-3.2.2/source/index/intervalrtree/IntervalRTreeBranchNode.cpp \
    geos-3.2.2/source/index/intervalrtree/IntervalRTreeLeafNode.cpp \
    geos-3.2.2/source/index/intervalrtree/IntervalRTreeNode.cpp \
    geos-3.2.2/source/index/intervalrtree/SortedPackedIntervalRTree.cpp \
    geos-3.2.2/source/index/quadtree/DoubleBits.cpp \
    geos-3.2.2/source/index/quadtree/IntervalSize.cpp \
    geos-3.2.2/source/index/quadtree/Key.cpp \
    geos-3.2.2/source/index/quadtree/NodeBase.cpp \
    geos-3.2.2/source/index/quadtree/Node.cpp \
    geos-3.2.2/source/index/quadtree/Quadtree.cpp \
    geos-3.2.2/source/index/quadtree/Root.cpp \
    geos-3.2.2/source/index/strtree/AbstractNode.cpp \
    geos-3.2.2/source/index/strtree/AbstractSTRtree.cpp \
    geos-3.2.2/source/index/strtree/Interval.cpp \
    geos-3.2.2/source/index/strtree/ItemBoundable.cpp \
    geos-3.2.2/source/index/strtree/SIRtree.cpp \
    geos-3.2.2/source/index/strtree/STRtree.cpp \
    geos-3.2.2/source/index/sweepline/SweepLineEvent.cpp \
    geos-3.2.2/source/index/sweepline/SweepLineIndex.cpp \
    geos-3.2.2/source/index/sweepline/SweepLineInterval.cpp \
    geos-3.2.2/source/inlines.cpp \
    geos-3.2.2/source/io/ByteOrderDataInStream.cpp \
    geos-3.2.2/source/io/ByteOrderValues.cpp \
    geos-3.2.2/source/io/CLocalizer.cpp \
    geos-3.2.2/source/io/ParseException.cpp \
    geos-3.2.2/source/io/StringTokenizer.cpp \
    geos-3.2.2/source/io/Unload.cpp \
    geos-3.2.2/source/io/WKBReader.cpp \
    geos-3.2.2/source/io/WKBWriter.cpp \
    geos-3.2.2/source/io/WKTReader.cpp \
    geos-3.2.2/source/io/WKTWriter.cpp \
    geos-3.2.2/source/io/Writer.cpp \
    geos-3.2.2/source/linearref/ExtractLineByLocation.cpp \
    geos-3.2.2/source/linearref/LengthIndexedLine.cpp \
    geos-3.2.2/source/linearref/LengthIndexOfPoint.cpp \
    geos-3.2.2/source/linearref/LengthLocationMap.cpp \
    geos-3.2.2/source/linearref/LinearGeometryBuilder.cpp \
    geos-3.2.2/source/linearref/LinearIterator.cpp \
    geos-3.2.2/source/linearref/LinearLocation.cpp \
    geos-3.2.2/source/linearref/LocationIndexOfLine.cpp \
    geos-3.2.2/source/linearref/LocationIndexOfPoint.cpp \
    geos-3.2.2/source/noding/BasicSegmentString.cpp \
    geos-3.2.2/source/noding/FastNodingValidator.cpp \
    geos-3.2.2/source/noding/FastSegmentSetIntersectionFinder.cpp \
    geos-3.2.2/source/noding/IntersectionAdder.cpp \
    geos-3.2.2/source/noding/IntersectionFinderAdder.cpp \
    geos-3.2.2/source/noding/IteratedNoder.cpp \
    geos-3.2.2/source/noding/MCIndexNoder.cpp \
    geos-3.2.2/source/noding/MCIndexSegmentSetMutualIntersector.cpp \
    geos-3.2.2/source/noding/NodedSegmentString.cpp \
    geos-3.2.2/source/noding/NodingValidator.cpp \
    geos-3.2.2/source/noding/Octant.cpp \
    geos-3.2.2/source/noding/OrientedCoordinateArray.cpp \
    geos-3.2.2/source/noding/ScaledNoder.cpp \
    geos-3.2.2/source/noding/SegmentIntersectionDetector.cpp \
    geos-3.2.2/source/noding/SegmentNode.cpp \
    geos-3.2.2/source/noding/SegmentNodeList.cpp \
    geos-3.2.2/source/noding/SegmentString.cpp \
    geos-3.2.2/source/noding/SegmentStringUtil.cpp \
    geos-3.2.2/source/noding/SimpleNoder.cpp \
    geos-3.2.2/source/noding/SingleInteriorIntersectionFinder.cpp \
    geos-3.2.2/source/noding/snapround/HotPixel.cpp \
    geos-3.2.2/source/noding/snapround/MCIndexPointSnapper.cpp \
    geos-3.2.2/source/noding/snapround/MCIndexSnapRounder.cpp \
    geos-3.2.2/source/noding/snapround/SimpleSnapRounder.cpp \
    geos-3.2.2/source/operation/buffer/BufferBuilder.cpp \
    geos-3.2.2/source/operation/buffer/BufferInputLineSimplifier.cpp \
    geos-3.2.2/source/operation/buffer/BufferOp.cpp \
    geos-3.2.2/source/operation/buffer/BufferParameters.cpp \
    geos-3.2.2/source/operation/buffer/BufferSubgraph.cpp \
    geos-3.2.2/source/operation/buffer/OffsetCurveBuilder.cpp \
    geos-3.2.2/source/operation/buffer/OffsetCurveSetBuilder.cpp \
    geos-3.2.2/source/operation/buffer/RightmostEdgeFinder.cpp \
    geos-3.2.2/source/operation/buffer/SubgraphDepthLocater.cpp \
    geos-3.2.2/source/operation/distance/ConnectedElementLocationFilter.cpp \
    geos-3.2.2/source/operation/distance/ConnectedElementPointFilter.cpp \
    geos-3.2.2/source/operation/distance/DistanceOp.cpp \
    geos-3.2.2/source/operation/distance/GeometryLocation.cpp \
    geos-3.2.2/source/operation/GeometryGraphOperation.cpp \
    geos-3.2.2/source/operation/IsSimpleOp.cpp \
    geos-3.2.2/source/operation/linemerge/EdgeString.cpp \
    geos-3.2.2/source/operation/linemerge/LineMergeDirectedEdge.cpp \
    geos-3.2.2/source/operation/linemerge/LineMergeEdge.cpp \
    geos-3.2.2/source/operation/linemerge/LineMergeGraph.cpp \
    geos-3.2.2/source/operation/linemerge/LineMerger.cpp \
    geos-3.2.2/source/operation/linemerge/LineSequencer.cpp \
    geos-3.2.2/source/operation/overlay/EdgeSetNoder.cpp \
    geos-3.2.2/source/operation/overlay/ElevationMatrixCell.cpp \
    geos-3.2.2/source/operation/overlay/ElevationMatrix.cpp \
    geos-3.2.2/source/operation/overlay/LineBuilder.cpp \
    geos-3.2.2/source/operation/overlay/MaximalEdgeRing.cpp \
    geos-3.2.2/source/operation/overlay/MinimalEdgeRing.cpp \
    geos-3.2.2/source/operation/overlay/OverlayNodeFactory.cpp \
    geos-3.2.2/source/operation/overlay/OverlayOp.cpp \
    geos-3.2.2/source/operation/overlay/PointBuilder.cpp \
    geos-3.2.2/source/operation/overlay/PolygonBuilder.cpp \
    geos-3.2.2/source/operation/overlay/snap/GeometrySnapper.cpp \
    geos-3.2.2/source/operation/overlay/snap/LineStringSnapper.cpp \
    geos-3.2.2/source/operation/overlay/snap/SnapIfNeededOverlayOp.cpp \
    geos-3.2.2/source/operation/overlay/snap/SnapOverlayOp.cpp \
    geos-3.2.2/source/operation/overlay/validate/FuzzyPointLocator.cpp \
    geos-3.2.2/source/operation/overlay/validate/OffsetPointGenerator.cpp \
    geos-3.2.2/source/operation/overlay/validate/OverlayResultValidator.cpp \
    geos-3.2.2/source/operation/polygonize/EdgeRing.cpp \
    geos-3.2.2/source/operation/polygonize/PolygonizeDirectedEdge.cpp \
    geos-3.2.2/source/operation/polygonize/PolygonizeEdge.cpp \
    geos-3.2.2/source/operation/polygonize/PolygonizeGraph.cpp \
    geos-3.2.2/source/operation/polygonize/Polygonizer.cpp \
    geos-3.2.2/source/operation/predicate/RectangleContains.cpp \
    geos-3.2.2/source/operation/predicate/RectangleIntersects.cpp \
    geos-3.2.2/source/operation/predicate/SegmentIntersectionTester.cpp \
    geos-3.2.2/source/operation/relate/EdgeEndBuilder.cpp \
    geos-3.2.2/source/operation/relate/EdgeEndBundle.cpp \
    geos-3.2.2/source/operation/relate/EdgeEndBundleStar.cpp \
    geos-3.2.2/source/operation/relate/RelateComputer.cpp \
    geos-3.2.2/source/operation/relate/RelateNode.cpp \
    geos-3.2.2/source/operation/relate/RelateNodeFactory.cpp \
    geos-3.2.2/source/operation/relate/RelateNodeGraph.cpp \
    geos-3.2.2/source/operation/relate/RelateOp.cpp \
    geos-3.2.2/source/operation/union/CascadedPolygonUnion.cpp \
    geos-3.2.2/source/operation/valid/ConnectedInteriorTester.cpp \
    geos-3.2.2/source/operation/valid/ConsistentAreaTester.cpp \
    geos-3.2.2/source/operation/valid/IndexedNestedRingTester.cpp \
    geos-3.2.2/source/operation/valid/IsValidOp.cpp \
    geos-3.2.2/source/operation/valid/QuadtreeNestedRingTester.cpp \
    geos-3.2.2/source/operation/valid/RepeatedPointTester.cpp \
    geos-3.2.2/source/operation/valid/SimpleNestedRingTester.cpp \
    geos-3.2.2/source/operation/valid/SweeplineNestedRingTester.cpp \
    geos-3.2.2/source/operation/valid/TopologyValidationError.cpp \
    geos-3.2.2/source/planargraph/algorithm/ConnectedSubgraphFinder.cpp \
    geos-3.2.2/source/planargraph/DirectedEdge.cpp \
    geos-3.2.2/source/planargraph/DirectedEdgeStar.cpp \
    geos-3.2.2/source/planargraph/Edge.cpp \
    geos-3.2.2/source/planargraph/Node.cpp \
    geos-3.2.2/source/planargraph/NodeMap.cpp \
    geos-3.2.2/source/planargraph/PlanarGraph.cpp \
    geos-3.2.2/source/planargraph/Subgraph.cpp \
    geos-3.2.2/source/precision/CommonBits.cpp \
    geos-3.2.2/source/precision/CommonBitsOp.cpp \
    geos-3.2.2/source/precision/CommonBitsRemover.cpp \
    geos-3.2.2/source/precision/EnhancedPrecisionOp.cpp \
    geos-3.2.2/source/precision/SimpleGeometryPrecisionReducer.cpp \
    geos-3.2.2/source/simplify/DouglasPeuckerLineSimplifier.cpp \
    geos-3.2.2/source/simplify/DouglasPeuckerSimplifier.cpp \
    geos-3.2.2/source/simplify/LineSegmentIndex.cpp \
    geos-3.2.2/source/simplify/TaggedLineSegment.cpp \
    geos-3.2.2/source/simplify/TaggedLinesSimplifier.cpp \
    geos-3.2.2/source/simplify/TaggedLineString.cpp \
    geos-3.2.2/source/simplify/TaggedLineStringSimplifier.cpp \
    geos-3.2.2/source/simplify/TopologyPreservingSimplifier.cpp \
    geos-3.2.2/source/util/Assert.cpp \
    geos-3.2.2/source/util/GeometricShapeFactory.cpp \
    geos-3.2.2/source/util/math.cpp \
    geos-3.2.2/source/util/Profiler.cpp
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
# -DOMIT_GEOS=0
# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
#LOCAL_MODULE    := spatialite
#LOCAL_CFLAGS    := -D__ANDROID__ -Dfdatasync=fsync
#LOCAL_LDLIBS   := -llog 
#LOCAL_C_INCLUDES := \
    libiconv-1.13.1/include \
    libiconv-1.13.1/libcharset/include \
    geos-3.1.1/source/headers \
    geos-3.1.1/capi \
    proj-4.6.1/src
#LOCAL_SRC_FILES := \
    ./libspatialite-amalgamation-2.3.1/spatialite.c \
    ./libspatialite-amalgamation-2.3.1/empty.cpp \
    ./libspatialite-amalgamation-2.3.1/sqlite3.c
#LOCAL_STATIC_LIBRARIES := iconv proj geos
#include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
# -DOMIT_GEOS=0
# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
LOCAL_MODULE    := spatialite
LOCAL_CFLAGS    := -D__ANDROID__ -Dfdatasync=fsync -DOMIT_GEOCALLBACKS
LOCAL_LDLIBS    := -llog 
LOCAL_C_INCLUDES := \
    libiconv-1.13.1/include \
    libiconv-1.13.1/libcharset/include \
    geos-3.2.2/source/headers \
    geos-3.2.2/capi \
    proj-4.6.1/src
LOCAL_SRC_FILES := \
    ./libspatialite-amalgamation-2.4.0/spatialite.c \
    ./libspatialite-amalgamation-2.4.0/empty.cpp \
    ./libspatialite-amalgamation-2.4.0/sqlite3.c
LOCAL_STATIC_LIBRARIES := iconv proj geos
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := jsqlite
LOCAL_CFLAGS    := -D__ANDROID__ \
    -DHAVE_SQLITE3=1 \
    -DHAVE_SQLITE3_LOAD_EXTENSION=1 \
    -DCANT_PASS_VALIST_AS_CHARPTR=1 \
    -Dfdatasync=fsync
LOCAL_LDLIBS    := -llog
LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/libspatialite-amalgamation-2.4.0/headers/spatialite \
    $(LOCAL_PATH)/javasqlite-20110106/native/
LOCAL_SRC_FILES := \
    javasqlite-20110106/native/sqlite_jni.c \
    javasqlite-20110106/native/empty.cpp \
    libspatialite-amalgamation-2.4.0/sqlite3.c
LOCAL_STATIC_LIBRARIES := spatialite iconv proj geos
include $(BUILD_SHARED_LIBRARY)

Application.mk:

APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
Frohnzie
  • 3,559
  • 1
  • 21
  • 24
  • I also had a issue with linking C and C++ libs. I followed the suggestion in this post and added a empty.cpp to each of the c libs as a workaround... http://code.google.com/p/android/issues/detail?id=16627 – Frohnzie May 25 '11 at 00:41
  • I'd love to have you submit a patch to the project here: https://github.com/mrenouf/android-spatialite – magneticMonster May 25 '11 at 13:35
  • I know Git is the new "hotness", but I am pretty clueless when it comes to GitHub. I did create a project at Google Code http://code.google.com/p/spatialite-android/ – Frohnzie May 25 '11 at 13:56
0

I have also one working project with Spatialite (3.0 beta) on Android: https://bitbucket.org/nutiteq/android-map-samples . You can also get prebuilt binaries from the downloads over there.

JaakL
  • 4,107
  • 5
  • 24
  • 37
0

For a Chinese post of compiling successfully under windows and cygwin, please ref this post: http://blog.newnaw.com/?p=1012