spatialite for iOS 编译方法

本文档详细介绍了如何在iOS环境中使用Homebrew安装必要的依赖,并通过git克隆项目来编译Spatialite及其依赖库,包括SQLite、GEOS和PROJ.4。此外,还提供了在XCode中设置Spatialite的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Compiling Spatialite for iOS

Since this took me a while to figure out, I figured I'd document it here in case it's useful to others later.

First, install compiler dependencies. (If you don't already have Homebrew installed, you'll need to do that first.)

brew install automake autoconf libtool libxml2 pkg-config
brew link libxml2

Build libspatialite from a very nice makefile that downloads and compiles libspatialite and its dependencies, SQLite, GEOS and PROJ.4.

git clone https://github.com/gstf/libspatialite-ios.git
cd libspatialite-ios
make

The result is a folder, lib, containing several .a files, as well as an include folder containing many .h files. 

Create a new XCode project.

Copy the libspatialite binaries and "include" folder into a folder named "libspatialite" in the XCode project folder.

In the XCode project's "Build Settings", you'll need to set the library and header search paths:

Library Search Paths: $(PROJECT_DIR)/AppName/libspatialite

Header Search Paths: $(PROJECT_DIR)/AppName/libspatialite/include

Drag the .a files into your project.

From the "Build Phases" window, add the following to the section "Link Binary With Libraries":

  • libz.dylib 
  • libxml2.2.dylib 
  • libc++.dylib 
  • libcharset.1.0.0.dylib 
  • libiconv.dylib

Now you should be able to use spatialite! To test if everything worked, just make your AppDelegate output the spatialite version.

Add the following to AppDelegate.m

#include <sqlite3.h>
#include <spatialite/gaiageo.h>
#include <spatialite.h>

In your application:didFinishLaunchingWithOptions: method, add:

spatialite_init (0);
printf("Spatialite version: %s\n", spatialite_version());

Compile and run and you should see the version output in the console!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值