使用 xcode 构建 Sqlite ICU [英] Building Sqlite ICU with xcode

查看:33
本文介绍了使用 xcode 构建 Sqlite ICU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将带有 ICU(Unicode 国际组件)的 sqlite 编译为 iPhone 应用工作区中的项目?

How do I compile sqlite with ICU (International Components for Unicode) as a project in my iPhone app's workspace?

我之前编译过 sqlite 合并,但是我不确定应该下载哪些文件,以及需要将哪些脚本添加到 xcode - 当然我不是第一个需要它的人.

I've compiled the sqlite amalgamation before, however I'm not sure what files I should download, and what scripts need to be added to xcode - surely I'm not the first to need this.

理想情况下,我正在寻找分步说明.

Ideally I'm looking for step-by-step instructions.

推荐答案

这是一个相当古老的问题,但 b/c 我花了相当多的时间自己构建 ICU 版本我想分享我的经验.基本上我提出了这个问题并从这里的 sqlite 邮件列表获得帮助 https://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg112029.html

This is a rather old question but b/c I spent quite some time in building an ICU version myself I would like to share my experience. Basically I raised the question and get the help from sqlite mail list here https://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg112029.html

所以首先使用 brew 安装 icu4c,但有一个问题,b/c brew 拒绝链接 icu4c.所以我需要在我的路径中添加icu4c

So first using brew to install icu4c, but with a catch, b/c brew refuses to link icu4c. So I need to add icu4c in my path

qiulangs-MacBook-Pro:fts qiulang$ brew info icu4c
icu4c: stable 62.1 (bottled) [keg-only]
C/C++ and Java libraries for Unicode and globalization
http://site.icu-project.org/
/usr/local/Cellar/icu4c/62.1 (250 files, 67.3MB)
  Poured from bottle on 2018-07-05 at 15:12:09
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/icu4c.rb
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

其次,从 https://www 下载 sqlite-autoconf tar.sqlite.org/download.html然后像这样运行配置,(如果配置输出的第一行是 bash: icu-config: command not found 然后检查为什么 icu4c 不在你的路径中.)

Second, download the sqlite-autoconf tar from https://www.sqlite.org/download.html Then just run configure like this, (if the first line of your configure output is bash: icu-config: command not found then check why icu4c wasn't in your path.)

./configure CFLAGS="-DSQLITE_ENABLE_ICU `icu-config --cppflags`" LDFLAGS="`icu-config --ldflags`"

我没有设置 LDFLAGS &CPPFLAGS 正如 brew 建议的那样,我仍然使用输出 creating Makefile 成功运行配置,然后运行 ​​make 以构建 ICU 版本.我相信在那之后你想仔细检查它的工作原理.这是我使用的示例代码:

I didn't set LDFLAGS & CPPFLAGS as brew suggests and I still run configure successfully with output creating Makefile , then run make to build an ICU version. I believe after that you would like to double check it works. This is the sample codes I used:

sqlite> CREATE VIRTUAL TABLE zh_text USING fts4(text, tokenize=icu zh_CN);
sqlite> INSERT INTO zh_text values('为什么不支持中文 Can icu support Chinese');
sqlite> CREATE VIRTUAL TABLE zh_terms USING fts4aux(zh_text);
sqlite> SELECT term, col, documents FROM zh_terms;
can|*|1
can|0|1
chinese|*|1
chinese|0|1
icu|*|1
icu|0|1
support|*|1
support|0|1
不|*|1
不|0|1
中文|*|1
中文|0|1
为什么|*|1
为什么|0|1
支持|*|1
支持|0|1
sqlite> CREATE VIRTUAL TABLE icu_zh_cn USING fts3tokenize(icu, zh_CN);
sqlite> SELECT token, start, end, position FROM icu_zh_cn WHERE INPUT='为什么不支持中文 fts5 does not seem to work for chinese';
为什么|0|9|0
不|9|12|1
支持|12|18|2
中文|18|24|3
fts5|25|29|4
does|30|34|5
not|35|38|6
seem|39|43|7
to|44|46|8
work|47|51|9
for|52|55|10
chinese|56|63|11

fts5 似乎还不支持 ICU 标记器,所以我只能使用 fts3 或 fts4.

fts5 seems not support ICU tokenizer yet so I can only fts3 or fts4.

sqlite> CREATE VIRTUAL TABLE zh_text5 USING fts5(text, tokenize=icu zh_CN);
Error: parse error in "tokenize=icu zh_CN"

这篇关于使用 xcode 构建 Sqlite ICU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆