SQLite:构建FTS5可加载扩展的麻烦

时间:2017-10-17 15:38:45

标签: c sqlite

我在Mac上尝试将FTS5构建为可加载的扩展程序。

我已经下载了SQLite源代码,成功执行了./configuremake fts5,获得了fts5.{c,h}个文件。

现在,当我尝试为扩展程序构建动态库时,我得到了:

gcc -g -fPIC -dynamiclib -o fts5.dylib fts5.c
In file included from fts5Int.h:18:0:
fts5_storage.c: In function 'sqlite3Fts5StorageOpen':
fts5_storage.c:305:9: error: 'sqlite3_api_routines' has no member named '__builtin___snprintf_chk'
In file included from /usr/include/secure/_string.h:33:0,
                 from /usr/include/string.h:192,
                 from fts5Int.h:21:
fts5_storage.c:305:26: warning: passing argument 1 of '__builtin_object_size' makes pointer from integer without a cast
fts5_storage.c:305:26: note: expected 'const void *' but argument is of type 'int'
In file included from fts5Int.h:18:0:
fts5_storage.c:308:11: error: 'sqlite3_api_routines' has no member named '__builtin___snprintf_chk'
In file included from /usr/include/secure/_string.h:33:0,
                 from /usr/include/string.h:192,
                 from fts5Int.h:21:
fts5_storage.c:308:28: warning: passing argument 1 of '__builtin_object_size' makes pointer from integer without a cast
fts5_storage.c:308:28: note: expected 'const void *' but argument is of type 'int'

我做错了什么?

我已经在macOS上尝试了MacPorts的gcc 4.9和5.5

有趣的是,在Linux(和gcc5)上我收到了这个错误:

❯ gcc -g -fPIC -shared -o fts5.so fts5.c
fts5.h:24:21: fatal error: sqlite3.h: No such file or directory
compilation terminated.

确实在sources目录的根目录中没有sqlite3.h,虽然我希望它应该在make步骤中创建? 我当然可以安装libsqlite3-dev,但我已经拥有了所有的sqlite源代码,为什么我呢?

1 个答案:

答案 0 :(得分:1)

感谢SQLite开发团队的Dan Kennedy现在解决了这个问题。

第一个问题似乎是在macOS上编译时SQLite源代码的实际问题,现在已在此处修复:http://www.sqlite.org/src/info/cd0471ca9f75e7c8

第二个问题是关于未生成的头文件,因为它需要单独的make步骤。所以完整的构建指令实际上是这样的:

./configure
make fts5.c sqlite3.h sqlite3ext.h
gcc -O2 -fPIC -shared fts5.c -o fts5.dylib