Reputation: 651
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?
Upvotes: 2
Views: 1866
Reputation: 591
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.
Upvotes: 2