我在 OS X Yosemite 上安装 Spatialite 工具时遇到问题,首先我已经阅读了在 OS X 上安装 Spatialite for python (GeoDjango)但它并没有帮助我解决问题。
在这里,我将提供我为使用 Homebrew 安装 spatialite 所做的步骤。
1)安装最新的sqlite3
brew install sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.8.8.3.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/sqlite-3.8.8.3.yosemite.bottle.tar.gz
==> Pouring sqlite-3.8.8.3.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
OS X provides an older sqlite3.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/sqlite/lib
CPPFLAGS: -I/usr/local/opt/sqlite/include
==> Summary
/usr/local/Cellar/sqlite/3.8.8.3: 9 files, 2.1M
2) 安装 libspatialite
brew install libspatialite
==> Downloading https://homebrew.bintray.com/bottles/libspatialite-4.2.0_1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/libspatialite-4.2.0_1.yosemite.bottle.tar.gz
==> Pouring libspatialite-4.2.0_1.yosemite.bottle.tar.gz
/usr/local/Cellar/libspatialite/4.2.0_1: 26 files, 17M
3)安装spatialite-tools
brew install spatialite-tools
==> Downloading https://homebrew.bintray.com/bottles/spatialite-tools-4.2.0.yosemite.bottle.3.tar.gz
Already downloaded: /Library/Caches/Homebrew/spatialite-tools-4.2.0.yosemite.bottle.3.tar.gz
==> Pouring spatialite-tools-4.2.0.yosemite.bottle.3.tar.gz
/usr/local/Cellar/spatialite-tools/4.2.0: 21 files, 804K
4) 到目前为止看起来不错,让我们尝试使用 spatialite
spatialite -version
SQLite header and source version mismatch
2015-02-25 13:29:11 9d6c1880fb75660bbabd693175579529785f8a6b
2014-12-09 01:34:36 f66f7a17b78ba617acde90fc810107f34f1a1f2e
所以看起来spatialite是建立在sqlite3之上的(f66f7a17b78ba617acde90fc810107f34f1a1f2e)但不是(9d6c1880fb75660bbabd693175579529785f8a6b)
当前版本 3.8.8.3 9d6c1880fb75660bbabd693175579529785f8a6b
所需版本 3.8.7.4 f66f7a17b78ba617acde90fc810107f34f1a1f2e
要解决此问题,我需要手动安装 sqlite 3.8.7.4 而不是 3.8.8.3,后者是 homebrew 中的最新版本
6)删除当前安装的sqlite
brew remove sqlite
brew unlink sqlite
7)安装sqlite 3.8.7.4
从这里下载 tarbal https://www.sqlite.org/src/info/f66f7a17b78ba617acde90fc810107f34f1a1f2e并解压内容
安装
./configure
sudo make clean
sudo make
sudo make install
8)尝试创建spatialite数据库
spatialite geo.db "SELECT InitSpatialMetaData();"
dyld: lazy symbol binding failed: Symbol not found: _sqlite3_rtree_geometry_callback
Referenced from: /usr/local/lib/libspatialite.7.dylib
Expected in: /usr/local/lib/libsqlite3.0.dylib
dyld: Symbol not found: _sqlite3_rtree_geometry_callback
Referenced from: /usr/local/lib/libspatialite.7.dylib
Expected in: /usr/local/lib/libsqlite3.0.dylib
Trace/BPT trap: 5
所以问题是它在库中找不到 _sqlite3_rtree_geometry_callback ......
请指出我做错了什么或者是否有更好的方法可以在 OS X 上安装它
感谢您的时间