how to compile spatialite for iOS
Asked Answered
J

4

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.

Jook answered 25/1, 2011 at 13:18 Comment(4)
What have you tried so far? I found this, might help: groups.google.com/group/spatialite-users/browse_thread/thread/…Mutualism
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.Jook
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 appGal
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.Jook
T
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

Tildie answered 1/2, 2011 at 14:29 Comment(10)
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.Swinge
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 !Tildie
Why the binary is so huge: 80MB .a file? I have compiled Spatialite for Android with NDK here and it is below 7 MB, over 10x smaller.Perigee
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.Perigee
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% :/Tildie
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.Recollection
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.Popovich
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 ?Tildie
In XCode 4.6 I get the linker error: file is universal (2 slices) but does not contain a(n) armv7s slice:Tamasha
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.aContrived
S
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

Swinge answered 28/1, 2011 at 17:35 Comment(0)
N
1

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

Nocturn answered 1/2, 2011 at 14:39 Comment(0)
B
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!

Bruni answered 26/5, 2013 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.