user1401064
user1401064

Reputation: 11

sqlite3 library undefined reference error

I am creating a word list searcher in C for my program using sqlite3 but I've got these errors .
I tried whatever I knew but it didn't fixed. I guess the problem is in my join function but I am not sure.

code :

bool *gb_wordlist_add_to_list (gbwordlist *word_list,char *str)
{
int sql_error;
char *error_massage;
if (gb_wordlist_in_list (word_list,str))
    {
    sql_error = sqlite3_execute(word_list->database, gb_wordlist_join(ADD_TO_TABLE_COMMAND"\'",str,"\';"),
                                NULL ,NULL, &error_massage);    
    if( sql_error!=SQLITE_OK )
    {
        fprintf(stderr, "SQL error: %s\n", error_massage);
        sqlite3_free(error_massage);
        return 0;
    }

    }
else
    return 0;

}


char *gb_wordlist_join (char *s1,char *s2,char *s3){
char *s;
s = malloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
if(s)
{
    strcpy(s,s1);
    strcat(s,s2);
    strcat(s,s3);
}
return s;
}

error:

gb-sql.o: In function `gb_wordlist_remove_from_list':
/home/reza/Project/GB/Search algorithm/Source/gb-search/src/gb-sql.c:104: undefined reference to `sqlite3_execute'

Also my full codes are here. Thanks a lot!

Upvotes: 0

Views: 500

Answers (1)

another.anon.coward
another.anon.coward

Reputation: 11395

The reason you are getting undefined reference to sqlite3_execute is well there is no such function as part of library. You probably meant to use sqlite3_exec (which use have used in some parts of the code).
Side Notes:

  1. The function gb_wordlist_callback is returning int but has been declared to return int*. You should change the return type to int to match the expected parameters to be passed to sqlite3_exec(after modifying from sqlite3_execute)
  2. The 4th parameter passed to sqlite3_exec (after modifying from sqlite3_execute) is expected to be void* so existance should be &existance
  3. You have quite a few functions with mismatch between return type declared and the actual return type returned from the function.
  4. Compile your code with -Wall -Wextra compiler options & fix all the warnings. It is good practice.

Hope this helps!

Upvotes: 1

Related Questions