Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-20-2011, 06:59 PM   #1 (permalink)
Registered Member
 
mebarron's Avatar
 
Join Date: Apr 2009
Location: Michigan
Posts: 47
mebarron is on a distinguished road
Default Successful uses of sqlite on iPhone, but fails on i386

Please forgive the fact that this question is coming from the wrong
direction, i.e., iPhone -> MacOSX i386

I have a Universal iPhone/iPad app that uses sqlite. At a point
in the app I need to get the Maximum ID for an entity in the
database.
The Project for this app includes:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libsqlite3.0.dylib

There is no corresponding dylib found beneath
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/MacOSX.platform
I want to use the same sqlite methods in a MacOSX program

When I include this same dylib in the i386 project, I get an error
that the file

ld: file not found: /usr/lib/system/libdispatch_sim.dylib for architecture i386

When I remove the reference to the dylib from the Xcode project, then I get
multiple errors with symbols not found , for example:
"_sqlite3_open", referenced from:
-[AppDelegate fetchMaxRecipeId] in AppDelegate.o

Do I need to compile a dynamic library from sqlite.c specific for i386 ??
if so, where do I find the right commandline
for gcc ???? Or is there a simpler fix. I am stumped.

Many Thanks, Mark

- (NSNumber*) fetchMaxRecipeId {
NSNumber *theMax;
sqlite3 *database;
NSString *databaseName = DATA_FILENAME_EXT;
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *dbPath = [documentsDir stringByAppendingPathComponent:databaseName];
//NSLog(@"2nd:documentsPath=%@\ndocumentsDir=%@\ndat abasePath=%@",documentPaths,documentsDir,dbPath);
// Open the database from the users filessytem
theMax = 0;
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
//const char *sqlStatement = "SELECT * FROM mynotes";// table name
const char *sqlStatement = "SELECT MAX( ZRECIPEID) FROM ZRECIPE";// table name
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
//[recipeNotes removeAllObjects];
/*
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *aNote = [NSString stringWithUTF8Stringchar *)sqlite3_column_text(compiledStatement, 3)];
NSNumber *aRid = [NSNumber numberWithIntint)sqlite3_column_int(compiledStat ement, 2)];
// Create a note object with the data from the database
RecipeNote *aRecipeNote = [[RecipeNote alloc] initWithNote:aNote Rid:aRid];
// Add the mynotes object to the RecipeNote Array
[recipeNotes addObject:aRecipeNote];
[aRecipeNote release];
}*/
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
theMax = [NSNumber numberWithIntint)sqlite3_column_int(compiledStat ement, 0)];
}


}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);

}
sqlite3_close(database);
return theMax;
}
mebarron is offline   Reply With Quote
Reply

Bookmarks

Tags
dylib, sqlite, symbol(s) not found

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 345
11 members and 334 guests
condor304, Creativ, Domele, dreamdash3, laureix68, LEARN2MAKE, michelle, mistergreen2011, Sami Gh, shagor012, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,662
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, shagor012
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:31 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0