编译sqlite3的拼写 [英] Compiling spellfix for sqlite3

查看:152
本文介绍了编译sqlite3的拼写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立「这是你的意思吗?功能到我的网站。我使用sqlite3并且学会了我可以使用spellfix模块通过levenstein订购表。



我下载了 sqlite3的源代码,并编译spellfix.c(它在/ ext / misc /),如下所示:

  gcc -shared -fPIC -Wall -I / tmp / sqlite-src-3071700 / spellfix.c -o spellfix 



它编译成功,但是当我加载到sqlite:

  sqlite> .load ./spellfix 

我收到此错误:

 错误:./spellfix:未定义符号:sqlite3_extension_init 


$ b b

我真的很少有关于编译c程序的知识。我做了一些错误编译或其他事情发生了吗?我应该怎么办?

解决方案

看起来sqlite init函数丢失了。这里有一个讨论 http:// sqlite。 1065341.n5.nabble.com/SQLite-version-3-7-16-td67776.html



我在顶部添加了以下代码。

/ p>

  static int spellfix1Register(sqlite3 * db); 

int sqlite3_extension_init(sqlite3 * db,char ** pxErrMsg,const sqlite3_api_routines * pApi){
SQLITE_EXTENSION_INIT2(pApi);
return spellfix1Register(db);
}

还需要以下,因为我无法拉入sqlite3_stricmp函数,不会产生额外的问题:

  int sqlite3_stricmp(const char * zLeft,const char * zRight){
return strcasecmp (zLeft,zRight)。
}

也需要这样:

  #define SQLITE_CONSTRAINT_NOTNULL(SQLITE_CONSTRAINT |(5 << 8))


b $ b

然后它编译并似乎正确运行。


I needed wanted to build "did you mean this?" feature to my website. I'm using sqlite3 and learned that i can use spellfix module to order tables via levenstein.

I downloaded source code of sqlite3 and compiled spellfix.c (it's inside /ext/misc/) like this:

gcc -shared -fPIC -Wall -I/tmp/sqlite-src-3071700/ spellfix.c -o spellfix

It compiles successfuly but when i load it into sqlite:

sqlite> .load ./spellfix

I'm getting this error:

Error: ./spellfix: undefined symbol: sqlite3_extension_init

I really have very few knowledge about compiling c programs. Did i do some mistake about compiling or something else is happened? What should i do?

解决方案

It seems the sqlite init function is missing. There is a discussion here http://sqlite.1065341.n5.nabble.com/SQLite-version-3-7-16-td67776.html

I added the following code at the top.

static int spellfix1Register(sqlite3 *db); 

int sqlite3_extension_init(sqlite3 *db, char ** pxErrMsg, const sqlite3_api_routines *pApi){
    SQLITE_EXTENSION_INIT2(pApi);
    return spellfix1Register(db);
}

Also needed the following since I couldn't pull in the headers for the sqlite3_stricmp function without creating additional problems:

int sqlite3_stricmp(const char *zLeft, const char *zRight){
    return strcasecmp(zLeft, zRight);
}

And needed this too:

#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))

Then it compiled and seemed to function correctly.

这篇关于编译sqlite3的拼写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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