5

I am new here and this is my first topic. I am very new on iOS platform and i am trying to use spatialiate extension with sqlite3 but i couldn't do this. It is making me crazy. I don't know how and where do i start. Can someone give me suggestion?

Thanks.

Nacrug
  • 133
  • 3
  • 9
  • What have you tried so far? I found this, might help: http://groups.google.com/group/spatialite-users/browse_thread/thread/f3b5941da7eded8d?pli=1 – badgerr Jan 25 '11 at 13:25
  • Thanks for replying. I looked the link before, but i didn't understand exactly. I just want to add spatialite library to my project and load it. However, when i try to load with .load 'SpatiaLite.dylib' it says there is no such load. What do i want at first? I want to put small region in database and i can find my place on this region offline. – Nacrug Jan 25 '11 at 13:54
  • Dynamic libraries aren't supported on the iPhone. You need to build any frameworks you wish to include as static libraries. This question might be helpful here: [Compiling custom SQLite for an iPhone app](http://stackoverflow.com/questions/823706/compiling-custom-sqlite-for-an-iphone-app) – Brad Larson Jan 25 '11 at 18:09
  • Thanks for your help. Actually i understood how to compile for iOS. However, There is a problem with the building or installing spatialite on mac os i am working on it. Thanks again. – Nacrug Jan 26 '11 at 16:24

4 Answers4

13

I'm the guy who shared the libs on http:// ;-) I did some good progress on easing the integration of spatialite for iOS. Now I'm able to build a fully standalone static library of spatialite (2.3.1 that embeds the required GEOS and PROJ so that don't have to take car of them).

Just download the zip http://lionel.gueganton.free.fr/spatialite/spatialite2.3.1.zip and you'll get the .a for x86 and arm + headers so that you can use directly the spatialite interface from those headers.

Once you've drag n drop the .a (both are required to work in the simulator AND on the real hardware), you can initialize spatialite by just invoking spatialite_init(1).

The following should be displayed on your console log:

SpatiaLite version ..: 2.3.1    Supported Extensions:
    - 'VirtualShape'    [direct Shapefile access]
    - 'VirtualText      [direct CSV/TXT access]
    - 'VirtualNetwork   [Dijkstra shortest path]
    - 'RTree'       [Spatial Index - R*Tree]
    - 'MbrCache'        [Spatial Index - MBR cache]
    - 'VirtualFDO'      [FDO-OGR interoperability]
    - 'SpatiaLite'      [Spatial SQL - OGC]
PROJ.4 version ......: Rel. 4.6.1, 21 August 2008
GEOS version ........: 3.1.1-CAPI-1.6.0

Michael Kohne
  • 11,888
  • 3
  • 47
  • 79
yonel
  • 7,855
  • 2
  • 44
  • 51
  • Many, many, thanks for this yonel, I *almost* feel guilty for receiving the points for this answer :-( . Of course, I'll be grabbing a copy of your binaries directly. Thanks again. – Big Rich Feb 01 '11 at 21:05
  • Give me my points back ! ;) I'm joking :) If you have the opportunity to give a try to them, I'm really interested in your feedback. As Vlad said in an answer, you'll have to add stdlib++.dylib to the Xcode project as GEOS (that is part of the .a) is a C++ code that uses the std lib. Cheers ! – yonel Feb 02 '11 at 08:32
  • Why the binary is so huge: 80MB .a file? I have compiled Spatialite for Android with NDK [here](https://bitbucket.org/nutiteq/android-map-samples/src/25d5b69e145e/jni) and it is below 7 MB, over 10x smaller. – JaakL Jan 04 '12 at 15:31
  • Ok, I see now why it is so huge. It includes whole GEOS (also functions not used by Spatialite, perhaps can be excluded with some switch?), and two copies of everything as it is fat library (both armv6 and armv7). Final application build will be optimized and just a few MB overhead. – JaakL Jan 10 '12 at 19:52
  • Hi, yes the static lib .aggregates spatialite + PROJ and GEOS. I think that symbols that are not used directly by spatialite are excluded by the build process but I can't guarantee that 100% :/ – yonel Jan 10 '12 at 20:31
  • It looks like there might be a typo in the header file. I'm getting linker errors when I try to call dump_shapefile or load_shapefile. – Kellen May 17 '12 at 04:57
  • Am I missing something? I can't find the instructions on how to build it. I would like to build one without PROJ and GEOS. – huggie Jun 27 '12 at 09:01
  • 1
    hum, spatialite has evolved since that post. Version 3.0.0 has been out since a while, so I would recommend to check at this one. Moreover, why would you want to have it without PROJ and GEOS ? You won't get much from spatialite without those two projects, will you ? – yonel Jul 01 '12 at 13:12
  • In XCode 4.6 I get the linker error: file is universal (2 slices) but does not contain a(n) armv7s slice: – tmanthey Apr 11 '13 at 07:14
  • I am getting this warning, how to resolve this `ld: warning: ignoring file /Users/apple/spatialiteDemo2/SpatialiteFiles/lib/libSPATIALITE_2.3.1_arm.a,missing required architecture x86_64 in file /Users/apple/Documents/spatialiteDemo2/spatialiteDemo2/SpatialiteFiles/lib/libSPATIALITE_2.3.1_arm.a (2 slices) ld: warning: ignoring file /Users/apple/spatialiteDemo2/SpatialiteFiles/lib/libSPATIALITE_2.3.1_x86.a, file was built for archive which is not the architecture being linked (x86_64):/Users/apple/spatialiteDemo2/SpatialiteFiles/lib/libSPATIALITE_2.3.1_x86.a` – Simeryn Denis May 14 '18 at 09:28
3

Roll up, Roll up, get them while they're hot!

Masters, the Google-fu is strong in this one!

Can't say I wrote this (I do plan on having CMake scripts for both iPhone SQLite and Spatialite, sometime real soon), but I suggest you get yourselves over to this site, before 404:

http://lionel.gueganton.free.fr/spatialite/

go download you some goodies, including pre-compiled Spatialite + extensions 2.3.1 binaries!!!.

There is an SQLite-on-OSX Cmake script (originally found here), which, with probably little work, should be re-targetable at SQLite-iPhone builds (I'll do it, just as soon as I get the time). This should allow you to use the latest SQLite version (I've read that the Apple-included version is slightly crippled). Then, supposedly, you just have to reference the new header files in a local manner, i.e. using quotes

(e.g. "sqllitexxx.h")

instead of using angle brackets:

(<sqllitexoldx.h>)

So, do I get those juicy points ;-) ?

Cheers

Big Rich

Big Rich
  • 5,864
  • 1
  • 40
  • 64
1

Spatialite for iOS in 3 easy steps:

  1. Get the Makefile and patch from https://github.com/gstf/libspatialite-ios
  2. Type make
  3. There is no step 3

Hat tip to Gustaf Lindqvist for making this available!

Johan Kool
  • 15,637
  • 8
  • 64
  • 81
1

You may have to compile to armv7 target (optimised build), you should also link with stdlib++.dylib.

Vlad
  • 191
  • 1
  • 3