Closed mro closed 10 years ago
Cool! I haven't used a triple store so far and I will not use one in the near term, but I'm happy to pull in a branch that does. Maybe you can use sqlite3 that ships with OS X so we don't need an extra step to brew it?
indeed, that's what I thought as well - but I'm clueless as how to tell pkg-config
about it...
That is a good point, there doesn't seem to be a sqlite.pc
for the native install. But since homebrew is required to build the C libraries anyway it's not really a problem.
It was already working with sqlite3 on iOS without any hack
interesting - how did you set up and use the storage?
SQLite is a dynamic library on OS X and iOS, apparently it's loaded on demand? @mro , if you can test that this works for you we can close this for good.
This works well (tested on iphone5 - ios7 device)
NSString *docsDir;
NSArray *dirPaths;
// Get the documents directory to check DB existence
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
// Build the path to the database file
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent: @"dbFileName.db"]];
// Creating, opening
NSFileManager *filemgr = [NSFileManager defaultManager];
if ([filemgr fileExistsAtPath: databasePath ] == NO)
{ // Database does not exist, we ask redland to create the tables, etc...
storage = [[RedlandStorage alloc] initWithFactoryName:@"sqlite" identifier:databasePath options:@"new='yes'"];
}
else{ // Redland normal initialization
storage = [[RedlandStorage alloc] initWithFactoryName:@"sqlite" identifier:databasePath options:@"new='no'"];
}
and then
model = [[RedlandModel alloc] initWithStorage:storage];
odd - the demo at https://github.com/mro/RedlandDemo/commit/d73c597d2f710c2ee37d7e32dfbd312a0c4de93e fails - bot on device and simulator:
2014-05-09 16:52:19.615 RedlandDemo[844:60b] Redland Error 0: {
facility = 14;
level = 4;
locator = "<00000000>";
message = "storage 'sqlite' not found";
}
2014-05-09 16:52:19.618 RedlandDemo[844:60b] initWithWrappedObject: Cannot wrap NULL object!
Any ideas?
Did you add the sqlite lib to the frameworks ?
You need to link sqlite3.dylib
.
Edit: dammit, too slow. ;)
have linked sqlite. Found it works on simulator 'iPhone Retina (4-inch 64-bit)' only. So it must be about .a linking?
Could you have a look at https://github.com/mro/RedlandDemo/commit/d73c597d2f710c2ee37d7e32dfbd312a0c4de93e - maybe you've got an idea (I'm clueless so far).
grep -B 1 "Triple stores enabled" Redland-source/build-*/redland-*/config.log
yields no mention of sqlite, so I doubt it's supported. (see also https://github.com/p2/RedlandDemo/commit/4441e8005a740fd548ee73316a22e4a254c98bf2#commitcomment-6347271)
@smamessier can you verify https://github.com/p2/RedlandDemo works with sqlite storage for you?
I could get it to run by the following recipe (but causing linker errors on all simulator builds except 'iPhone'):
$ cd Redland-source
$ grep -B 1 "Triple stores enabled" build-*/redland-*/config.log
$ grep -A 1 "checking using sqlite library" build-*/redland-*/config.log
$ pkg-config --exists --print-errors "sqlite3"
$ brew install sqlite3
$ ls -l /usr/local/Cellar/sqlite/*/lib/pkgconfig/
$ export PKG_CONFIG_PATH=/usr/local/Cellar/sqlite/*/lib/pkgconfig/
patch pp-configure.sh to look like this:
$ grep "export PKG_CONFIG_PATH" */pp-configure.sh
Mac/pp-configure.sh:export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
Sim/pp-configure.sh:export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
iOS/pp-configure.sh:export PKG_CONFIG_PATH="${SDKROOT}/usr/lib/pkgconfig:${DEVROOT}/usr/lib/pkgconfig:${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
$ ./start-over.sh
$ ./cross-compile.py
$ grep -B 1 "Triple stores enabled" build-*/redland-*/config.log
Issue is IMO how to persuade configure to use the shipped sqlite and not taint the PKG_CONFIG_PATH.
currently sqlite isn't available for storage - despite the linked sqlite library indicating such.
To achieve this, it seems to take a couple of steps:
--with-sqlite=3
toRedland-source/cross-compile-config.py
,Redland-source/*/pp-configure.sh
to hand on a previously setPKG_CONFIG_PATH
,$ brew install sqlite
,$ export PKG_CONFIG_PATH=/usr/local/Cellar/sqlite/*/lib/pkgconfig/
,$ grep "Triple stores enabled" Redland-source/build-*/redland-*/config.log
to containsqlite
,RedlandStorage *storage = [[RedlandStorage alloc] initWithFactoryName:@"sqlite" identifier:@"foo.sqlite" options:@"new='yes'"];
,foo.sqlite
may have to be an absolute path into e.g. theDocuments
directory,