Latest spatialite binaries for Android - cross compile

44 views
Skip to first unread message

Pedro Galriça

unread,
Jun 24, 2019, 9:40:31 AM6/24/19
to geopaparazzi-devel
Hi,

I'm a .NET/C# developer.

 

I’m developing (in Qt/ C++) a simple application that will run in mobile devices.

The goal of this future app is to give, in "real time", the pk of a roadway based on GPS location and a table of routes.


Until now we work with PostgreSQL/Postgis (desktop only), but we want to start using Sqlite/Spatialite for mobile. 

I don't have experience neither background in c/c++ programming.

 

The problem is building Spatialite for Android.

Well, because I'm developing in C++, I just only need to Cross Compile Spatialite (target aarch64 in my case)...

It's very important to have the latest binaries because of this issue https://www.gaia-gis.it/fossil/libspatialite/info/6763032337d71a2a


I've followed the NDK instructions from de NDK developers page https://developer.android.com/ndk/guides/other_build_systems  for Autoconf projects. 

I' ve setup a Linux VM (CentOS7) with Development Tools and Android NDK installed. 

In that machine I've already build (cross compile) with success simple libraries (without dependencies), like sqlite. Thus, it’s a good sign... :-) 

I've already cross compiled geos library (version 3.7.2) with success.

 

When trying to build librttopo (that depends of libgeos), the configure script exits with error " configure: error: could not find libgeos_c (or obsolete 'libgeos_c' < v.3.5.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig"

I'm absolute sure that geos is version 3.7.2...


The invocation of configure script was:

 

                ./configure --prefix=/home/pgalrica/build_local_android --with-geosconfig=/home/pgalrica/build_local_android/bin/geos-config --host aarch64-linux-android

 

Digging through configure.log, I see 2 different problems:

 

First problem:

                "/home/pgalrica/sources/librttopo/conftest.c:65: undefined reference to `GEOSContext_setErrorMessageHandler_r'

                clang: error: linker command failed with exit code 1 (use -v to see invocation)"

 

Second problem: warnings that libc++_shared.so and libm.so were not found followed by a bunch of undefined references associated to libgeos_c.so

                "/home/pgalrica/LocalTools/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libc++_shared.so, needed by /home/pgalrica/build_local_android/lib/libgeos_c.so, not found (try using -rpath or -rpath-link)

                /home/pgalrica/LocalTools/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libm.so, needed by /home/pgalrica/build_local_android/lib/libgeos_c.so, not found (try using -rpath or -rpath-link)

                /home/pgalrica/build_local_android/lib/libgeos_c.so: undefined reference to `std::__ndk1::ctype<char>::id' "

                 (....... and so on so on .....)


Can you help me? Some tips to cross compile or update spatialite library for the latest sources.


Thank you very much

Pedro

 

config.log

andrea antonello

unread,
Jun 24, 2019, 4:54:42 PM6/24/19
to geopaparazzi-devel
Hi Pedro,

[...]
The problem is building Spatialite for Android.

Well, because I'm developing in C++, I just only need to Cross Compile Spatialite (target aarch64 in my case)...

It's very important to have the latest binaries because of this issue https://www.gaia-gis.it/fossil/libspatialite/info/6763032337d71a2a

your timing might be a good one.

I was about to write to the list also to ask Mark if he is planning to do an updated build of the native libraries.
Mark is the person that has setup the whole documentation about building spatialite for android.

So before redirecting you to his documentations about how to build the libraries, I will chime in and ask an intermediate question. :-)

Mark, I have tested your last build (I think 5 months old) in the new VTM version I am developing and it works perfectly. 
It would be really awesome if you could do a build in near future.


Thanks,
Cheers,
Andrea



 

I've followed the NDK instructions from de NDK developers page https://developer.android.com/ndk/guides/other_build_systems  for Autoconf projects. 

I' ve setup a Linux VM (CentOS7) with Development Tools and Android NDK installed. 

In that machine I've already build (cross compile) with success simple libraries (without dependencies), like sqlite. Thus, it’s a good sign... :-) 

I've already cross compiled geos library (version 3.7.2) with success.

 

When trying to build librttopo (that depends of libgeos), the configure script exits with error " configure: error: could not find libgeos_c (or obsolete 'libgeos_c' < v.3.5.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig"

I'm absolute sure that geos is version 3.7.2...


The invocation of configure script was:

 

                ./configure --prefix=/home/pgalrica/build_local_android --with-geosconfig=/home/pgalrica/build_local_android/bin/geos-config --host aarch64-linux-android

 

Digging through configure.log, I see 2 different problems:

 

First problem:

                "/home/pgalrica/sources/librttopo/conftest.c:65: undefined reference to `GEOSContext_setErrorMessageHandler_r'

                clang: error: linker command failed with exit code 1 (use -v to see invocation)"

 

Second problem: warnings that libc++_shared.so and libm.so were not found followed by a bunch of undefined references associated to libgeos_c.so

                "/home/pgalrica/LocalTools/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libc++_shared.so, needed by /home/pgalrica/build_local_android/lib/libgeos_c.so, not found (try using -rpath or -rpath-link)

                /home/pgalrica/LocalTools/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libm.so, needed by /home/pgalrica/build_local_android/lib/libgeos_c.so, not found (try using -rpath or -rpath-link)

                /home/pgalrica/build_local_android/lib/libgeos_c.so: undefined reference to `std::__ndk1::ctype<char>::id' "

                 (....... and so on so on .....)


Can you help me? Some tips to cross compile or update spatialite library for the latest sources.


Thank you very much

Pedro

 

--
You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/b8298780-23c0-4a31-8d3e-b5baaa53e140%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pedro Galriça

unread,
Jun 25, 2019, 5:45:50 AM6/25/19
to geopaparazzi-devel
Hi Andrea!

That would be great!
Thanks

Pedro
Hi Pedro,

[...]
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.

andrea antonello

unread,
Jul 1, 2019, 8:58:42 AM7/1/19
to geopaparazzi-devel
Hi Pedro,
I am talking with Sandro (from the spatialite project) about the possibility to create a docker image with the cross compilation environment to make building the native parts easier.
But it is still just a talk.

Were you able to follow Mark's compilation instructions on the WIKI?

Cheers,
Andrea





Hi Pedro,

[...]
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/cafe6a29-750e-44ba-b0ad-ab15c826e03b%40googlegroups.com.

Pedro Galriça

unread,
Jul 1, 2019, 10:46:44 AM7/1/19
to geopaparazzi-devel
Hi Andrea and Sandro,

I've studied a lot the documentation from Spatialite site and the wiki from Mark.
I was able to build successfully the binaries from the latest sources for windows (win10 + msys2) and for linux (Fedora 30, CentOS7). No problems.
The extension mod_spatialite works like a charm!!! :-) 

For android, there is a big problem (at least for me, is!!):
Mark's build don't work for me. Maybe because it only works with java wrappers. Maybe I make bad calls... I have worked in this with no success...
As  told you before, right now I'm developing in native c++ (Qt framework) and I don't understand the Android/system/architecture neither Android Studio/Java. I think that that library only works with Android Studio.

Because I only need the native c++ library, I tried to cross compile (for aarch64) Spatialite and all dependencies (the autoconf projects) . Every time, it exits with error messages saying that proj4, or geos, or iconv (when disabling one at a time) are not installed...
Something is wrong... I've read that Android doesn't like shared libraries. Maybe that is the problem. Or maybe some code changes are needed to have c++ runtime libraries compatibility.
Well, no matter the problem, it's like a hard/impossible mission for my level...

I can give some more detailed information of the building process that I followed, if important.

Thank you so much,
Cheers
Pedro




Hi Pedro,

[...]
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.

Pedro Galriça

unread,
Jul 9, 2019, 5:53:36 AM7/9/19
to geopaparazzi-devel
UPDATE:

Hi Andrea

I've already been able to call successfully the library from Qt. It was quite a challenge :-)
Right now, libjsqlite.so build with the latest sources solve the problem...

Thank you so much
Pedro

Pedro Galriça

unread,
Aug 9, 2019, 5:49:07 AM8/9/19
to geopaparazzi-devel
Hi All,

Is there any update?
Thank you so much.

Cheers
Pedro

andrea antonello

unread,
Aug 9, 2019, 5:53:42 AM8/9/19
to geopaparazzi-devel
Hi Pedro,
I thought you were following the discussion on the list and this issue:
https://github.com/geopaparazzi/geopaparazzi/issues/596

Geopaparazzi is currently working with a new build done by Mark. And
the version is sure what you are looking for.

Cheers,
Andrea
>>>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
>>>>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/b8298780-23c0-4a31-8d3e-b5baaa53e140%40googlegroups.com.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/af346d5a-047a-451b-abfb-f63dec1532bb%40googlegroups.com.

Pedro Galriça

unread,
Aug 9, 2019, 6:58:39 AM8/9/19
to andrea antonello, geopaparazzi-devel
Great!!
That's awesome!

Thank you very much
Cheers
Pedro

Pedro Galriça

unread,
Aug 14, 2019, 12:53:26 PM8/14/19
to geopaparazzi-devel
Update:

Hi All!

Just to say that I've downloaded from this link below the latest binaries builded from Mark and they work as they should.
Problem solved.


Thank you!
Cheers
Pedro

>>>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.

>>>>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/b8298780-23c0-4a31-8d3e-b5baaa53e140%40googlegroups.com.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.

>>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/cafe6a29-750e-44ba-b0ad-ab15c826e03b%40googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/geopaparazzi-devel/af346d5a-047a-451b-abfb-f63dec1532bb%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-devel+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages