Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:41:45+00:00 2026-06-03T05:41:45+00:00

I have create a database class and packaged some methods. However, once build the

  • 0

I have create a database class and packaged some methods. However, once build the project…

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.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

here are some critical methods:

create the database:

-(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; 
}

create tables:

-(BOOL)createTable:(NSString*)sqlCreateTable  
{  
if (![self openOrCreateDatabase:self.m_dbName]) {  
    return NO;  
}  
char *errorMsg;  
if (sqlite3_exec (self.m_sql, [sqlCreateTable UTF8String],NULL, NULL, &errorMsg) != 
SQLITE_OK)  
{  
    NSLog(@"创建数据表失败:%s",errorMsg);  
    return NO;  
}  
[self closeDatabase];  
return YES;  
}  

close the database:

-(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],0, NULL, &errorMsg) ==SQLITE_OK)  
{  [self closeDatabase];  
    return YES;}  
else {  
    printf("更新表失败:%s",errorMsg);  
    [self closeDatabase];  
    return NO;  
}  
return YES;  
}  

update tables:

-(BOOL)UpdataTable:(NSString*)sqlUpdata{  
if (![self openOrCreateDatabase:self.m_dbName]) {  
    return NO;  
}  
char *errorMsg;  
if (sqlite3_exec (self.m_sql, [sqlUpdata UTF8String],0, NULL, &errorMsg) !=SQLITE_OK)  
{  
    [self closeDatabase];  
    return YES;  
}else {  
    return NO;  
}  

return YES;  
}  

select records:

-(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];  
}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:41:47+00:00Added an answer on June 3, 2026 at 5:41 am

    You need to add the libsqlite library into linking process. This can be done in the Project Settings, see https://stackoverflow.com/a/7623043/1091195.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a unit-test for some python class. I have a database
I have the need to create a database for some data I have, and
I have some simple code which should create a database. package com.webfoo.android.databaseExample; import android.app.Activity;
i have created an options menu for my database class. Upon launching the options
I'm learning EF4.1 against the northwind database. I have created a POCO class like
I have created one user named tuser with create database rights in SQL server
I have to create logic for generation unique number identifier for records in database.
I have 2 tables in my mysql database: CREATE TABLE IF NOT EXISTS `RECIPES`
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation
I have recently changed my web app to create a database connection per command

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.