ios – i386的未定义符号:“_sqlite3_open”,引用来自:error

ios – i386的未定义符号:“_sqlite3_open”,引用来自:error,第1张

概述我已经创建了一个数据库类并打包了一些方法.但是,一旦建立项目… Undefined symbols for architecture i386:"_sqlite3_open", referenced from: -[MyDataBase openOrCreateDatabase:] in MyDataBase.o"_sqlite3_exec", referenced from: -[M 我已经创建了一个数据库类并打包了一些方法.但是,一旦建立项目…
Undefined symbols for architecture i386:"_sqlite3_open",referenced from:  -[MyDataBase openorCreateDatabase:] in MyDataBase.o"_sqlite3_exec",referenced from:  -[MyDataBase createtable:] in MyDataBase.o  -[MyDataBase Inserttable:] in MyDataBase.o  -[MyDataBase Updatatable:] in MyDataBase.o  -[MyDataBase querrytableByCallBack:] in MyDataBase.o"_sqlite3_close",referenced from:  -[MyDataBase closeDatabase] in MyDataBase.o"_sqlite3_get_table",referenced from:  -[MyDataBase querrytable:] in MyDataBase.old: symbol(s) not found for architecture i386clang: error: linker command Failed with exit code 1 (use -v to see invocation)

这里有一些关键的方法:

创建数据库:

-(BOol)openorCreateDatabase:(Nsstring*)dbname { self.m_dbname = dbname; NSArray *path =NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES); Nsstring *documentsDirectory = [path objectAtIndex:0]; if(sqlite3_open([[documentsDirectory stringByAppendingPathComponent:dbname]   UTF8String],&m_sql) !=sqlITE_OK) { NSLog(@"创建数据库失败"); return NO; } return YES; }

创建表:

-(BOol)createtable:(Nsstring*)sqlCreatetable  {  if (![self openorCreateDatabase:self.m_dbname]) {      return NO;  }  char *errorMsg;  if (sqlite3_exec (self.m_sql,[sqlCreatetable UTF8String],NulL,&errorMsg) != sqlITE_OK)  {      NSLog(@"创建数据表失败:%s",errorMsg);      return NO;  }  [self closeDatabase];  return YES;  }

关闭数据库:

-(voID)closeDatabase  {  sqlite3_close(self.m_sql);   }  //insert  -(BOol)Inserttable:(Nsstring*)sqlInsert  {  if (![self openorCreateDatabase:self.m_dbname]) {      return NO;  }  char* errorMsg = NulL;  if(sqlite3_exec(self.m_sql,[sqlInsert UTF8String],&errorMsg) ==sqlITE_OK)  {  [self closeDatabase];      return YES;}  else {      printf("更新表失败:%s",errorMsg);      [self closeDatabase];      return NO;  }  return YES;  }

更新表:

-(BOol)Updatatable:(Nsstring*)sqlUpdata{  if (![self openorCreateDatabase:self.m_dbname]) {      return NO;  }  char *errorMsg;  if (sqlite3_exec (self.m_sql,[sqlUpdata UTF8String],&errorMsg) !=sqlITE_OK)  {      [self closeDatabase];      return YES;  }else {      return NO;  }  return YES;  }

选择记录:

-(NSArray*)querrytable:(Nsstring*)sqlQuerry  {  if (![self openorCreateDatabase:self.m_dbname]) {      return nil;  }  int row = 0;  int column = 0;  char*    errorMsg = NulL;  char**    dbResult = NulL;  NSMutableArray*    array = [[NSMutableArray alloc] init];  if(sqlite3_get_table(m_sql,[sqlQuerry UTF8String],&dbResult,&row,&column,&errorMsg )   == sqlITE_OK)  {      if (0 == row) {          [self closeDatabase];          return nil;      }      int index = column;      for(int i =0; i < row ; i++ ) {            NSMutableDictionary*    dic = [[NSMutableDictionary alloc] init];          for(int j =0 ; j < column; j++ ) {              if (dbResult[index]) {                  Nsstring*    value = [[Nsstring alloc]   initWithUTF8String:dbResult[index]];                  Nsstring*    key = [[Nsstring alloc] initWithUTF8String:dbResult[j]];                  [dic setobject:value forKey:key];                  [value release];                  [key release];              }              index ++;          }           [array addobject:dic];          [dic release];      }     }else {      printf("%s",errorMsg);      [self closeDatabase];      return nil;     }     [self closeDatabase];     return [array autorelease];  }
解决方法 你需要将libsqlite库添加到链接过程中.这可以在项目设置中完成,参见 https://stackoverflow.com/a/7623043/1091195. 总结

以上是内存溢出为你收集整理的ios – i386的未定义符号:“_sqlite3_open”,引用来自:error全部内容,希望文章能够帮你解决ios – i386的未定义符号:“_sqlite3_open”,引用来自:error所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1112052.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存