我从http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz下载了sqlite。
我该如何编译带有icu的sqlite?
1)你可以将它编译为SQLite的动态扩展。 引用http://www.sqlite.org/cvstrac/fileview?f=sqlite/ext/icu/README.txt
The easiest way to compile and use the ICU extension is to build and use it as a dynamically loadable SQLite extension. To do this using gcc on *nix:
gcc -shared icu.c `icu-config --cppflags --ldflags` -o libSqliteIcu.so
You may need to add "-I" flags so that gcc can find sqlite3ext.h and sqlite3.h. The resulting shared lib, libSqliteIcu.so, may be loaded into sqlite in the same way as any other dynamically loadable extension.
(在SQLite提示符中加载.load libSqliteIcu.so
正在加载)
2) 您可以启用ICU编译SQLite。根据http://www.sqlite.org/compile.html,您应该定义宏SQLITE_ENABLE_ICU
:
将-DSQLITE_ENABLE_ICU
添加到CFLAGS变量中或在某个配置文件中添加#define SQLITE_ENABLE_ICU
。
好的,这里有一些标准文档中未描述的内容。以下是启用ICU的configure调用示例:
CFLAGS='-O3 -DSQLITE_ENABLE_ICU' CPPFLAGS=`icu-config --cppflags` LDFLAGS=`icu-config --ldflags` ./configure
您还需要安装icu-config
程序(它来自于libicu
或libicu-dev
包)。
libSqliteIcu.so
,因为当我加载它时,我会得到这个错误。sqlite> .load ./libSqliteIcu.so
Error: dlsym(0x7fa073e02c60, sqlite3_sqliteicu_init): symbol not found
在sqlite邮件列表上提问后,我被告知确认了以下内容。
该符号名称为sqlite3_icu_init。当您加载模块lib<x>.so
时,将调用符号sqlite3_<x>_init
。您需要将共享库重命名为正确的名称(libicu.so
)或在加载模块时向加载器传递init函数的名称(sqlite3_icu_init),或者在icu.c
源文件中更改sqlite3_icu_init
函数的名称,以使其与模块加载器正在查找的名称匹配...
要启用带有ICU的SQLite编译,您应该定义宏SQLITE_ENABLE_ICU
。
确保您已安装libicu-dev
(在Debian / Ubuntu上)。
正如@osgx所写,标准文档缺少ICU特定的标志,您还需要设置这些标志。icu-config
已被弃用,并且在Ubuntu 20.04及以后版本中缺失,因此您应改用pkg-config
:
CFLAGS="-O2 -DSQLITE_ENABLE_ICU `pkg-config --libs --cflags icu-uc icu-io`" ./configure
make
请参见:
Error: unknown tokenizer: icu
。 - ariefs ^~~~~~~~~~~~~~~~~~
- aeroxr1
icu-config --ldflags
并检查其输出是否包含-Bstatic或-Bdynamic。如果没有,则将LDFLAGS更改为LDFLAGS="-Wl,-Bstatic "\
icu-config --ldflags`" -Wl,-Bdynamic"`。 - osgxsudo apt update && sudo apt install libicu-dev libsqlite3-dev -y
- pouya