问题
I am at the end of my sanity trying to get spatialite to compile with xcode 4.5 for iOS6 (or any other version). Actually, I can get it to compile using a technique based on Build a static library for iOS - specifically spatialite where the console returns that all is oK but when I run a query such as
"select pk_uid from uk_highways order by GLength(geometry) limit 2" the statement won't prepare.
Running the query "select pk_uid from uk_highways limit 2" will return 2 id's i.e. taking out the spatial function - works fine (and yes, there is a geometry column in the table)
I have been banging my head for 3 days now and really need some help, I hate to say it but I think I even need an "idiots guide" if there is one out there.
EDIT: not sure why I didn't include this first time round:
-(int)getStreetLength
{
int length;
NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"dhub_spatial" ofType:@"sqlite"];
sqlite3 *db;
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK)
{
NSLog(@"***** database opened ********");
spatialite_init(1);
char *sql = "SELECT pk_uid from united_kingdom_highways where pk_uid < 100 order by GLength(Geometry) limit 2;";
sqlite3_stmt *stmt;
if (sqlite3_prepare(db, sql, -1, &stmt, NULL) == SQLITE_OK)
{
NSLog(@"***** statement prepared ********");
while (sqlite3_step(stmt) == SQLITE_ROW)
{
NSLog(@"***** all the way throug to the while loop ********");
length = sqlite3_column_int(stmt, 0);
NSLog(@"the value of pkuid is %i",length);
}
}
else
{
NSLog(@"could not prepare statement: %s\n", sqlite3_errmsg(db)); //this returns no such function GLength
}
}
return length;
}
来源:https://stackoverflow.com/questions/13221006/spatialite-ios5-and-xcode-4-5-could-not-prepare-statement-no-such-function-g